Some extra info: This is connected to an html file of code, but the html code doesn't show because it's in a different file, and I can't be bothered to fetch it. When I run this, the console shows a random number from 1-10, but the textContent ALWAYS shows "you rolled a 1". Does anyone know why this happens?
//Random Number
function randomRange() {
return Math.floor(Math.random() * 10);
}
var randomNumber = randomRange()
console.log(randomNumber);
//button changing onClick
const button = document.querySelector("#button");
function test() {
button.style.color = "red";
button.style.background = "black";
if (randomNumber = 0) {
button.textContent = "You Rolled a 0"
} else if (randomNumber = 1) {
button.textContent = "You Rolled a 1"
} else if (randomNumber = 2) {
button.textContent = "You Rolled a 2"
} else if (randomNumber = 3) {
button.textContent = "You Rolled a 3"
} else if (randomNumber = 4) {
button.textContent = "You Rolled a 4"
} else if (randomNumber = 5) {
button.textContent = "You Rolled a 5"
} else if (randomNumber = 6) {
button.textContent = "You Rolled a 6"
} else if (randomNumber = 7) {
button.textContent = "You Rolled a 7"
} else if (randomNumber = 8) {
button.textContent = "You Rolled a 8"
} else if (randomNumber = 9) {
button.textContent = "You Rolled a 9"
} else if (randomNumber = 10) {
button.textContent = "You Rolled a 10"
}
};