I have this code:
function raffle(){
number = Math.random(100) * 100;}
raffle();
But everytime I raffle(); the number is the same.
Math.random()
returns an a random number between 0 (inclusive) and 1 (exclusive). The Javascript random
function doesn't take any parameters.
If you want a random number x such that 0 ≤ x < 100, then you would do:
function raffle() {
return Math.random() * 100;
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments