I've tried making if statements that activate other if statements, but both of them ran at the same time.
I also tried else if statements, but that didn't seem to work...
So, how would I make: an if statement that activates once the past if statement has been run and the button is pressed again.
I hope that makes any sense in y'alls head. The help would be appreciated. :)
let One = true
let Two = false
let Three = false
function right() {
if (One === true) {
if (Two === false) {
document.getElementById("2").innerHTML = 1
document.getElementById("1").innerHTML = ''
Two = true
One = false
} else {
if (Three === false) {
document.getElementById("3").innerHTML = 1
document.getElementById("2").innerHTML = ''
Three = true
Two = false
}
}
}
}
the state variable keeps track of the current state. Each time the right function is called, it checks the value of state and updates the elements accordingly. The state variable is then updated to the next state so that the next if statement will run on the next button click.