Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Web Technology by (47.6k points)

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?

1 Answer

0 votes
by (106k points)

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;

Related questions

0 votes
1 answer
0 votes
1 answer
asked Feb 26, 2021 in Python by laddulakshana (16.4k points)
0 votes
1 answer

Browse Categories

...