Boolean problem, always false


No matter what answer you type for your age, it always end up displaying "let's start!" as if it was always false, why?

confirm("I am ready to play!");
var age = prompt("What's your age");
if( "age" < 13 )
    console.log("allowed to play but we don't take any responsability");
    console.log("let's start!");


if( "age" < 13 ) // remove ""

you cant compare string vs number


Take age out of quotes in the if statement. You're checking the variable, not comparing a string to an int.


Remove the quotes from around age in your if statement.

With the quotes there, you are comparing the literal string "A-G-E". We want to compare the variable so we use age without quotes.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.