You can generate a random number between 2 and 15 in javascript using the following code:
index.tsx55 chars2 lines
Explanation:
Math.random()
generates a random number between 0 and 1.Math.floor()
rounds down the result to the nearest integer.The randomNumber
variable will now hold a random integer between 2 and 15.
gistlibby LogSnag