If / else statement, useranswer


#1


Hello! 

I'm having trouble with the piece of code below: 

var userAnswer = prompt ("Do you want to race Bieber on stage?");
if (userAnswer === "yes") {
    ("You and Bieber start racing. It's neck and neck! You win by a schoelace!")}
    else { 
        ("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'")}

I get the error 'Oops, try again. Did you remember to put in the 'yes' answer option?' but I can't seem to find what is incorrect in the code.


#2

HI these lines

    ("You and Bieber start racing. It's neck and neck! You win by a schoelace!")
   ("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'")

its missing the console.log

ANd It will says

@mdusseljee
that you don't have the if statement you shoudn't remove the if statement that check for the age


#3

Hi! I've added that, but it doesn't help...


#4

The if statement for the age is still in there. This is the entire code so far:
// Check if the user is ready to play!
confirm ("are you ready to play?");
var age = prompt ("What's your age?");
if (age < 13) {
console.log ("You can play, but we are not taking any responsiblity") }
else {
console.log ("Great! Enjoy the game!!!")}
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 === "yes") {
console.log ("You and Bieber start racing. It's neck and neck! You win by a schoelace!")}
else {
console.log ("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'")}

And still getting the error


#5

Funny thing is, the code works (both answers "yes" and "no" give the correct answer). I'm just getting an error and don't know why...


#6

this is your string

"You and Bieber start racing. It's neck and neck! You win by a schoelace!"

here what the lesson give you

"You and Bieber start racing. It's neck and neck! You win by a shoelace!"

you wrote schoelace instead of shoelace


#7

That's it! Thank you!!


#9

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