Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript random numbers

let randomNum = Math.floor(Math.random() * 5)

return( 0 or 1 or 2 or 3 or 4)

let randomNum = Math.floor(Math.random() * 5) + 1

return( 1 or 2 or 3 or 4)

// * 5 in this code meaning a number between 0 and 4 
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #javascript #random #numbers
ADD COMMENT
Topic
Name
9+1 =