5. What am i doing wrong?


#1

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

   if(age > 13) 
{
    console.log("you are not old enough");
}
   else
{
     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.'");
  }


#2

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

if (userAnswer "yes")

its missing something between userAnswer and "yes"


#3

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


#4

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


#5

i already did?

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

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


#6

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


#7

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


#8

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


#9

I showed you the help topic for it?


#10

First: Like Stated before you're missing a comparison
ex:
(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.

ex:
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!


#11

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


#12

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.


#13

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