I am stuck at #5


#1

I think the problem is in the if statement

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

Here:

if (userAnswer = "yes") {
  console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!")
{

Remember that:

  • === compares two values
  • = assigns a value

In an if statement, you should always use the first.

You also opened a curly bracket - { - instead of closing it - } - after your if statement.


#3

if (userAnswer = "yes") {
console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!")
{ <-- NEEDS TO BE CHANGED TO A CLOSED BRACKET NOT AN OPEN BRACKET
else {
console.log("Oh no! Bieber shakes his head and sings I set a pace, so I can race without pacing.'")
}


#4

I can't find my error on this and it says: SyntaxError: Unexpected Token ILLEGAL

This is the code: :arrow_down:
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 shoelace!")
}
else
{
console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'")
}[quote="pavlephoto, post:1, topic:25668, full:true"]
I think the problem is in the if statement

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.'")
}


#5

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.'")
}

When execute this code it says "Oops, try again. Did you add an if statement to your code?"

Can I know what went wrong ?


#6

I am having a similar problem, it says Did you put in a 'yes' answer option?
this is my code:
console.log("WE TAKE NO RESPONSIBLIY ABOUT YOU PLAYING THIS GAME");

} else {

console.log("This is my first game, so enjoy");

}
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 Biber start racing. It's neck and neck! You win by a shoelance!")
} else {
console.log("Oh no! Bieber shakes his head and sins 'I set a pace, so I can race without pacing.'")
}


#7

You are not the only one. I have the exact same thing. Admin please help us!!!!


#8

confirm("I am ready to play! Let's play");
var age = prompt("What's your age");
if (age<13) {
console.log("The game company will take no responsibility for player under 13");
}
else {
console.log("Perfekt! Ready for Ramboooo!");
}
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?'");
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 shoelace!");
}
else
{
console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");
}


#9

Hi astronautaccon, it looks like your issue is your missing semicolen ; at the end of your console.log strings. Othersise you look good man!


#10

I whoops one more thing that is throwing your code off astron, your if statement "is =" like when your declare a variable. You need "equal ===" in your if (userAnswer = "yes". Change it to ===. :smiley:


#11

I have the same problem, my code is "OK", but don't work...

// Check if the user is ready to play!
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 shoelace!");
    }
    else{
            console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");
    }

#12

i solve the problem, i change the "else" for other "if", in this case was...

if(userAnswer === "yes"){
console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!");
}
if(userAnswer === "no"){
console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");
}


#13

so then something is broken on the actual exercise i take it?


#14

worked perfectly fine.... however I did not try to ask for input before as i was just thinking to print out the story anyways. thanks for this code.


#15

My code also does not work. I get the error "SyntaxError: Unexpected token else"

var age = prompt("What's your age");
if (age < 13 ) {
console.log("This is a warning");
}
else {
console.log("Wonderful");
}
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 shoelace!");
}

else
{
console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'")
}


#16

HI next time its' better if you create a new topic with your code instead of posting on an old post 2 month later

then

this line you should remove the ; after the if condition

if (userAnswer === "yes"); <== this one

#17

thank you so much i didn't realize


#18

var userAnswer = prompt("Do you want to race Bieber on stage?);
you lost a quote after ?


#19

Tente o seguinte:
confirm(" ?");
confirm(" !");

var userAswer = prompt(" ?");
if (userAnswer === "yes") {
console.log(" !");
}
else
{
console.log(" !");
}

var age = (" ?");
if (age < 13) {
console.log (" !");
}
else
{
console.log(" !");
}


#20

Thanks man, it really saved me