I stuck on this. Don't know what to do? Whatever the value i give 0 or 1 it always goes to else condition print.help me out?


#1


Help me out

https://www.codecademy.com/en/courses/javascript-beginner-en-x9DnD/0/5?curriculum_id=506324b3a7dffd00020bf661


Answer is same for what is choose. either yes or no in the condition.


// Check if the user is ready to play!
confirm("Yes I am ready")
var age = prompt("What is your age?");
if(age < 13)
{
console.log("under age, SORRY");    
    }
    else
    {
        console.log("welcome to our kingdom");
        }
        console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'");
        console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'");
        var userAnswer = prompt("Do you want to race Bieber on stage");
        if(userAnswer=0)
        {
            console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!");
            }
        else{
            console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.");
            }


#2

= one equal sign means assign
=== checking if its the same

Go like this
userAnswer === "yes"
then type in yes and see it will work :slight_smile:


#3

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