let x = Math.random()
console.log(x)
result: generates a new random number on each refresh
let x = Math.random() * 6
console.log(x)
result: generates a new random number on each refresh * 6
let x = Math.floor(Math.random() * 6) + 1
console.log(x)
result: generates a new random number on each refresh to 1 to 6
let x = Math.floor(Math.random() * 6) + 1
let y = Math.floor(Math.random() * 6) + 1
let z = Math.floor(Math.random() * 6) + 1
console.log(x)
console.log(y)
console.log(z)
result: generates 3 random numbers on each refresh to 1 to 6
Html
<label id="xLabel">Enter you name </label>
<label id="yLabel">Enter you name </label>
<label id="zLabel">Enter you name </label>
<button type="button" id="rollButton">roll</button>
Javascript
let x
let y
let z
document.getElementById("rollButton").onclick = function(){
x = Math.floor(Math.random() * 6) + 1
y = Math.floor(Math.random() * 6) + 1
z = Math.floor(Math.random() * 6) + 1
document.getElementById("xLabel").innerHTML = x
document.getElementById("yLabel").innerHTML = y
document.getElementById("zLabel").innerHTML = z
}
Monitor result ⬇️