how do i do random number generator js code example
Example 1: how to generate a random number in javascript
Math.random();
Math.floor(Math.random())
Math.floor(Math.random() * 10) + 1
Example 2: random number javascript
function uniqueNumber(count) {
let defaultNumber = 4413277523420
let convertToArray = defaultNumber.toString().split("")
let sliceNumber = convertToArray.slice(0, count)
let randomNumber = Math.floor((Math.random() * +sliceNumber.join("")));
if (randomNumber.toString().split("").length < count) {
randomNumber = Math.abs(randomNumber - +sliceNumber.join(""))
}
return randomNumber
}