Generate Random number from 1 to N
=============================
Below little snippet helps you in generating random number between 1 to N. Might come handy for your next JS game.
//random number from 1 to N var random = Math.floor(Math.random() * N + 1); //random number from 1 to 10 var random = Math.floor(Math.random() * 10 + 1); //random number from 1 to 100 var random = Math.floor(Math.random() * 100 + 1);
0 comments:
Post a Comment