1//To genereate a number between 0-1
2Math.random();
3//To generate a number that is a whole number rounded down
4Math.floor(Math.random())
5/*To generate a number that is a whole number rounded down between
61 and 10 */
7Math.floor(Math.random() * 10) + 1 //the + 1 makes it so its not 0.
1$("h1").html(Math.floor(Math.random() * 10)); // Generate a number between 0-9
2//Change 10 to the value you want to be the max number to generate
1function randomNumber(min, max) {
2 return Math.random() * (max - min) + min;
3}
1var randomNum ;
2randomNum = Math.ceil(Math.random() * 100);
3document.write("Random number between 1 and 100: " + randomNum)