Adding 2 ifs statements


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>

```

I may be jumping ahead of myself… but I would like to know how to add a third if in this code that would stop a user going above 10?

Would I simply add another if statement in? for example?
if (feedback > 10)
Stop trying to find bugs in my code

If this is going to be covered later you can tell me to go away :slight_smile:

// Check if the user is ready to play!
confirm(“Are you ready”)
var age = prompt(“What’s your age”)

if ( age < 13)
{
console.log(“Go ask mum”)
}
else
{
console.log(“Have fun!”)
}
{
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 (prompt == “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.’”)
}
var feedback = prompt (“Rate this out of 10, please”)

if (feedback > 8)
{
console.log(“Thank you! We should race at the next concert!”)
}

else
{
console.log(“I’ll keep practising coding and racing.”)
}

<do not remove the three backticks above>

#2

That comes a bit later.
You would use if/else. That is:
if ( age < 13) { console.log("Go ask mum") } else if(age < 10) { //code here } { console.log("Have fun!") }


#3

So like this?

var feedback = prompt (“Rate this out of 10, please”)

if (feedback > 8)
{
console.log(“Thank you! We should race at the next concert!”)
}

if (feedback > 10)
{
console.log(“Please use a number between 1 and 10.!”)
}

else
{
console.log(“I’ll keep practising coding and racing.”)
}


#4

No.

var feedback = prompt ("Rate this out of 10, please")

if (feedback > 8)
{
console.log("Thank you! We should race at the next concert!")
} else if (feedback > 10)
{
console.log("Please use a number between 1 and 10.!")
}

else
{
console.log("I'll keep practising coding and racing.")
}

#5

Like this:

don’t forget ending curly brackets and semi-colons!


#6

Thank you very much!


#7

Strangely the courses do not make you put in the semi-colons. Teaching me bad habits. :stuck_out_tongue: