5. The story heats up!


#1

I have written this:
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.'");
}

But I see error:
Oops, try again. Did you add an if statement to your code?

What's wrong?


#2

Add your previous section code that checks for age at the top of this code.


#3

That's all. When I push "Reset code" i see:
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?");

Instruction this topic:

Now you have to create different scenarios. Good thing we know how to do that using if / else statements.

If userAnswer is "yes", print out: "You and Bieber start racing. It's neck and neck! You win by a shoelace!"

Otherwise, print out: "Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'"

Remember: = is for assignment, and === is to check if things are equal!

I must use "if/else" and when i wrote it:
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.'");
}


#4

Go to this exercise copy the code from there and add at the top of your code.


#5

I see only 1 line in your exercise:
console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'");

but I have written it in my code (first line)

I try to compare my code with code 6th exercise but i don't see any differents.


#6

The link I have put there you,will link to your exercise not mine!
Can you put your current code and exercise youre on now?


#7

Ok, when i open this link i see my exercise. I have done that exercise a couple days ago. Now I open this link and have done it again. And have done all exercises till 5th exercise. Maybe I should to record video?


#8

I think I was not explicit when I said this..

Add your previous section code that checks for age at the top of this code.

It means..

//code of exercise 2 should be put on top of this exercise.
//then whatever code you wrote in this this exercise down to it.

Example..

say In exercise two I had to write this code..

ex2.

x = 4

In ex5.
I have got told to do this..

y = 45
z = "Ryan"

What Im saying you to do is this?

ex2
ex5

It means...

x = 4
y = 45
z = "Ryan"

#9

I was having the same problem, but when changed if (userAnswer === "yes") to if ("userAnswer === yes") and it all worked. I think the correct answer is if(userAnswer === yes). Neither you and I had it right, but for some reason it won't allow anything else besides
if ("userAnswer === yes")


#10

You need to put ex2 code at the top of this exercise's code and run it.


#11

I tried to change but I got errors.
I try:
if ("userAnswer === yes")
if(userAnswer === yes)
if (userAnswer === yes)
if (userAnswer === "yes")
e.t.c


#12

thank you, It works!


#13

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