Assignment 33: A Possible Answer


<SCRIPT LANGUAGE="javascript">
var user_number = prompt("I want a random number between 1 and...","Write it here")
var num = Math.round(user_number * Math.random());
document.write("Here's your random number between 1 and " +user_number+ ": " + num + ".")



Gives you this:

     The prompt is pretty common. Where you had to be reading is where I entered user_number in to the mathematical statement. Now, I am not returning a number and it is not inside of a document.write statement.
     Remember we said a couple of lessons back that surrounding a number with quotes sets it to zero? Well, those plus signs do the same. Lose them and it'll work just fine.


Did You Get It?


Back to the Index Page