Assignment 36: A Possible Answer

This:

<SCRIPT LANGUAGE="JavaScript">
var usernum = prompt("How long a random number should I create?","Write your number here")
loops=usernum
num=1
while (num <= loops)
{
var zip = Math.round(9 * Math.random());
document.write(zip)
num=num+1
}
</SCRIPT>

 

Gives you this:

 

     You get the effect by using the Math object method of generating random numbers. You can't use the getSomething() method because the numbers would most likely all be the same.

     The loop runs until the numbers have been posted.

 

Did You Get It?

 

Back to the Index Page