Whats wrong?


#1


// Check if the user is ready to play!
confirm ("are u ready??");
var age = prompt("What's your age");
if(age<13)
{
  console.log("Sorry you are too young to play ");
}
else
{
console.log("You are a beast");
}
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");
{
confirm ("You and Bieber start racing. It's neck and neck! You win by a shoelace!")
}
else(userAnswer="no");
{
confirm ("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'")
}
var feedback = prompt("Rate this game out of /10");
if (feedback =>8) {
console.log ("Thank you! We should race at the next concert!");
}
else
{
console.log ("I'll keep practicing coding and racing.");
}


#2

You want to compare userAnswer and the strings "yes" and "no" so you would use === rather than =.


#3

Ohh Ok Thanks so much


#4

I tried It still does not work ;(


#5

What's your error message? Also can you provide the link to the exercise?


#6

this is the error message SyntaxError: Unexpected token else


#7

Awesome thanks, can you also post your updated code, (formatted between backticks)


#8

// Check if the user is ready to play!
confirm ("are u ready??");
var age = prompt("What's your age");
if(age<13)
{
  console.log("Sorry you are too young to play ");
}
else
{
console.log("You are a beast");
}
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");
{
confirm ("You and Bieber start racing. It's neck and neck! You win by a shoelace!")
}
else(userAnswer==="no");
{
confirm ("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'")
}
var feedback = prompt("Rate this game out of /10");
if (feedback =>8) {
console.log ("Thank you! We should race at the next concert!");
}
else
{
console.log ("I'll keep practicing coding and racing.");
}

#9

Alright, you don't want your if and else statements to have these semi colons. The purpose of these in JS are to signal a stop, kind of like a period in our English language. You need to get rid of them so that the if and else statements can open. :slight_smile:


#10

ok thanks cause I know c# and the ; mix me up ;/


#11

That's okay! It happens a lot, so you just get better at remembering not to. Have a good day!


#12

Thanks for your time kyleaw :slight_smile: have a good day .


#13

Hello, so i've followed this code verbatim and my "syntax" is continuously wrong...


#14

can you give me your code in ticks please :wink:


#15

confirm("Are you ready to play?")
var age = prompt("Age please.");

if (age < 13)
{
console.log("You can't play.")
}
else
{
console.log("You can play.")
}

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?");

console.log("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 heaad and sings 'I set a pace, so I can race without pacing.'")
}
var feedback = prompt("Rate the game out of 10");
if(feedback <= 8)
{
console.log("Aiight, catch ya at the next show.");
}

else {
console.log("You be whack, too, dogg.");
}


#16

It's really just the last part that is continuously incorrect. So, var feeedback = prompt


#17

I actually figured it out lol. After var feedback...I needed to write console.log("Rate the game out of 10"). Then the if/else statement. Wow. I'm a newb. Sorry!!!


#18

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