Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript random number

//returns a random number between 1 and maxNumber
//replace Math.ceil with Math.round if you want to include 0 as well
const randomNumber = (maxNumber) => { 
	return Math.ceil(Math.random() * maxNumber);
}
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #javascript #random #number
ADD COMMENT
Topic
Name
2+3 =