Back
How can I generate random whole numbers between two specified variables in JavaScript, e.g. x = 4 and y = 8 would output any of 4, 5, 6, 7, 8?
If you want to generate random whole numbers in JavaScript in a specific range then you can use the below-mentioned code:-
var randomnumber = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
31k questions
32.8k answers
501 comments
693 users