I am writing a game and I have this problem: the last if
statement (and all its else if
statements) are never executed.
Here is the code that doesn’t work:
const compare = prompt("1.mars, 2.jupiter, 3.moon")
if (compare === 2) {
confirm("your airplane crashed and you died")
} else if (compare === 1) {
confirm("you arrived safely")
} else if (compare === 3) {
confirm("you survived an airplane crash but you need to escape")
}