The Story Heats up!


#1

Sorry for the long code but I need help. It says I have a syntax error and I can't seem to understand whats wrong? Any advice? Thank you.

confirm("Are you ready to play?");

var age = prompt("Whats your age");

if(age < 13) {
console.log("You can not 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?'");

confirm("Do you want to race Bieber on stage?")
var userAnswer = "yes"

if("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

ok here's your problem.

confirm("Do you want to race Bieber on stage")
var userAnswer = "yes"

Make this into this:

var userAnswer = confirm("Do you want to race Bieber on stage?");

and lastly change this:

if("yes") {

to this.

if( userAnswer == "yes"){

--EDIT--

You were on the right track and I understand what you were thinking, but I'd like to know if you understand what it's saying now.


#3

Ok Thank You so much! Lolman I was having some trouble on this one! :joy:


#4

My solution:

// Check if the user is ready to play!
if(confirm ("I am ready to play!")) {
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.'");
}
} else {
console.log("you are not ready to play")
}


#5

Hi my code is below, I don't understand where is mistake

confirm("I am ready to play!");
var age = prompt("What is your age");

if ("age is less than 13");
{
console.log("right");
}
else
{
console.log("wrong");
}

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 = confirm("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.'");
}

it says every time
There was a problem with your syntax.


#6

Hi this part

if ("age is less than 13"); <== remove this ;

you should change is less than with <
And remove the " "

and here

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

firts remove the ; after your if condition then
you should change = with `===.
because with one = your are saving the string "yes" inside the variable userAnswer


#8

Could I get some help with my code as well without having to start a new thread?

My code is posted below and I am getting an error code "Did you remember to put in the 'yes' answer option?". I just can't seem to find out what is wrong with this section of my code.


var userAnswer=prompt("Do you want to race Kylo on stage?");
//Yes or No racing question.
if (userAnswer==="yes")
{
console.log("You and Kylo start racing. It's neck and neck but you win by a Wookie hair!");
}
else
{
console.log("Oh no! Kylo Ren takes your refusal as an insult and slashes you down with his lightsaber after he stops sobbing like a little girl.");
}


#9

Hi when you saved & run your code did you type yes inside the console ?


#10

Yes I did. It doesn't matter if I type yes or no in the prompt box it still errors out with "Did you remember to put in the 'yes' answer option?".

I can't see anything wrong with the if/else statement but it is probably rite there staring at me.


#11

Can you Post all your code?


#12

Here you go. I didn't want to post all of it if it wasn't needed.
Thank you wizmarco for your time.


// Check if the user is ready to play!
confirm("Are you ready to play?");
confirm("I am ready to play!")
var age = prompt("What is your age?");
if (age<13)
{
console.log("Play at your own risk youngling.");
}
else
{
console.log("Play on playa!");
}
//Dialog.
console.log("You are at a First Order rally, and you hear Kylo Ren speak of the race for firepower superiority.");
console.log("Suddenly, Kylo stops and says, 'Who wants to race me?'");
var userAnswer=prompt("Do you want to race Kylo on stage?");
//Yes or No racing question.
if (userAnswer==="yes")
{
console.log("You and Kylo start racing. It's neck and neck but you win by a Wookie hair!");
}
else
{
console.log("Oh no! Kylo Ren takes your refusal as an insult and slashes you down with his lightsaber after he stops sobbing like a little girl.");
}


#13

Hi your code is right , can you try to refresh the page or to Change browser.


#14

I tried in a different browser and the same error code pops up. I'm stumped.


#15

I read a lot of feedback from others in forums that they are having the same glitch problems with the website. So, with that knowledge I skipped to the end of the section, saved and submitted my code, and it accepted it with out any error messages.

Maybe it is just the website? Any ideas from people smarter than I am??


#16

Try other thing try to use the string they gave you to put inside your console.log() .


#17

Hi guys. I need some help. Whenever I try to save the code and go on, I get this message:
Syntax Error: Unexpected Keyword 'else'
I am unsure of what to do.

This is my code:

confirm("Are you ready to play?");

var age = prompt("What's your age?");

if (age <13)
{
confirm("You are allowed to play. However, we take no responsibility for any psychological problems as a result of this game.");
}
else
{
confirm("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? Yes or No?");

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

Thank you for any help.


#18

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

Console works but This writes me : "Oops, try again. Did you add an if statement to your code?"


#19

Hi this part remove the ; after the if condition

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

#20

Hi this part

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

Try it like that

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

#21

I can't figure out what i did wrong! it always says Oops, try again. Did you add an if statement to your code?

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