Trying To Get A Random Number On Button Click
I'm trying to use javascript to get a random number in the range of 0-20 to display in a text box after the user clicks a button, but I am so far unsuccessful. What is the error in
Solution 1:
You function needs to return a value:
function makeid() {
return Math.floor(Math.random() * 20)
}
Solution 2:
You function does not return a value, which is why the input is being set to undefined
.
Try this instead:
function makeid() {
return Math.floor(Math.random() * 20);
}
Post a Comment for "Trying To Get A Random Number On Button Click"