// Request user to input a number, then a name. Using a for loop, the name is displayed repeatedly until the loop counter reaches the number entered by the user. Note that window.open will display the output inside a new window. var input = prompt("Input a number");
var name = prompt("What is your name?");
var i;
var myWindow = window.open("", "MsgWindow", "width=500,height=500");
for (i=1; i <= input; i++){
myWindow.document.write(i +" " +name);
}
// for loop checks each number iteration for divisible by 23 and if it is then displays the number var start;
var myWindow = window.open("", "MsgWindow", "width=500,height=500");
const end = 3000;
const divisible = 23;
for(start = 100; start <= end; start++){
if(start % 23 == 0)
myWindow.document.writeln(start +" is divisible by 23");
}
// Declares and initializes randome number equal to 0, then inside a while loop displays the random number if it is less than 0.99. Inside the while loop the random number is set equal to a new random number using Math.random() var random = 0;
var count = 0;
var myWindow = window.open("", "MsgWindow", "width=500,height=500");
while (random < 0.99){
random = Math.random();
count++
}
myWindow.document.writeln("Loop executed " +count +" times. Random number is: "+random);