How to show the action?


#1



Hi guys, I'm in "The Story Heats Up! part and have two questions.


My Code works great but there are two things that could be better. Maybe you can help me improve them.

1) The game doesnt show me "The Player" whats going on, it jumps between questions. Are you ready to play? How old are you? Are you ready to race beiber? But never shows me the story, the console only shows after i answered all the questions.

2) Are you ready to race Bieber? If I answer Yes it will take it as a no, since inside the if its a yes. How can i make it work with Yes as with yes.

Thanks! :slight_smile:


// Check if the user is ready to play!

confirm("Are you ready to play?");
var age = prompt ("What's you age?");

if (age < 13) {
    
    console.log("You are too young. Play anyway.");
} else {
    
    console.log("Rock It Man!");
};

console.log(" ");
console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'");

console.log(" ");
console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'");

var userAnswer = prompt("Do you want to race Biever on stage?")

if (userAnswer === "yes") {
    
    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

1)
It is not right i checked it and after two questions is can read in the console the Story and should answer the third question.

2)

if (userAnswer === "yes" || userAnswer === "Yes" || userAnswer ==="YES" || userAnswer ==="yes" )

Or better use the method toUpperCase();

var userAnswer = userAnswer.toUpperCase();
if (userAnswer === "YES" )

str.toUpperCase() Convert the string to uppercase letters

That means
yes,Yes,YES,yEs,YeS,yeS etc. will be accepted.