function to generate random number in js code example
Example 1: js random number
var random;
var max = 8
function findRandom() {
random = Math.floor(Math.random() * max) //Finds number between 0 - max
console.log(random)
}
findRandom()
Example 2: get random numbers javascript
//Write the following code to get a random number between 0 and n
Math.floor(Math.random() * n);