56.3k views
14 votes
How do I create a JavaScript random number generator with a range of 0-10?

I also have to list the number in the p tag num-display, and use an event listener to associate randomNum with num-display.

User Barzo
by
4.4k points

1 Answer

5 votes

Answer:

randomInt(min: number, max: number): number {

return Math.floor(Math.random() * (max - min + 1) + min);

}

Step-by-step explanation:

use randomInt(0,10) to get a number, with 0 and 10 inclusive.

User Kyogs
by
4.1k points