Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js random

Math.floor(Math.random() * 10) + 1 // Random number Between 1 and 10
// First Math.random give us a random number between 0 and 0,99999
// The we multiply it by 10
// And we round dow with Math.floor
// We add 1 so the result will never be 0 

// Another Example:
h.floor(Math.random() * 20) + 10 // Random number Between 10 and 20
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #js #random
ADD COMMENT
Topic
Name
8+5 =