[Solved] === won’t work even if the statement is true


Your variable age gets a String from the prompt.
For it to work you need to convert it to an int with the operator +:

If the use of the + operator feels strange to you in this case, you can always use the function parseInt() instead. It will achieve the same result.

var age = +prompt("What is your age?");
//        ^ Converts your String to an int
if (age === 21) {
 console.log("Happy 21st Birthday!");
}

6

solved === won’t work even if the statement is true