5. What am i doing wrong?

confirm("Are you ready to play?");
var age = prompt("What's your age");

   if(age > 13) 
    console.log("you are not old enough");
     console.log("you are old enough");
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 (userAnswer "no");
  console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");

HI the else statement doesn’t take a condition then here

if (userAnswer "yes")

its missing something between userAnswer and "yes"

if (userAnswer "yes")

you forgot to compare userAnswer with "yes". Else can’t have any conditions, else is simply:

else {
  /* do something */

No condition (userAnswer “no”). if you do want a condition, use else if

1 Like

you are saying its missing something in yes, plesse can you tell me, what is it ?

i already did?

if (userAnswer /* missing comparing operator */ "yes")

you are missing the comparison operator. Use two equals signs to compare values

1 Like

I am stuck in adding some story .
Can someone hdlp me out with this problem.

HI you should create a new topic with your code and the error your get

Hey I have a question. How do you post the code in a code format on the topic posts?

I showed you the help topic for it?

First: Like Stated before you’re missing a comparison
(userAnswer === yes)

Second: This will still give you an error, why? Simple theres no word yes aka it has not been defined aka you havent assign a value to the word yes.

Solution for the second part: on top of your if/else that is quoted on my post you need to give a value to the variable to yes since its not defined.

var yes = “yes”;

So the comparision if(userAnswer === yes) if the answer i received on the text box is yes and yes is equal to the answer it will run the code. If the user types something that is not “yes”, it will run the else.

Hope this explanation helped you! Happy Coding!

thank you, i’m sorry, i’m a smart person but all of this is hard for me

No need to be sorry, its part of the process of learning and understanding , it takes time and effort to achieve something so enjoy the ride.

A post was split to a new topic: 5. what i am doing wrong?