December 2013
Intermediate to advanced
384 pages
9h 54m
English
// Random number between 0 and 1 Math.random(); //Random number between 1 and 10 Math.floor(Math.random() * 10) + 1; //Random number between -10 and 10 Math.floor(Math.random() * 20) - 10;
The Math.random() function generates a random float value between 0 and 1. To convert that to an integer, multiply the results of Math.random() by the maximum value you want for the integer and then use Math.floor() to round it down.
Read now
Unlock full access