2nd if will not work


#1


asking for feedback


Although the exercise say it is correct the second if code will not show


feedback = prompt("out of 10 how would you rate this game"); {
}
if(userAnswer>="8") {
console.log ("Thank you! We should race at the next concert!")
}
if (userAnswer<="7") {
console.log ("I'll keep practicing coding and racing.")
}


#2

How does this code pass? The if conditions have an undefined variable.


#3

idk it just does and i want to know how to do it the correct way


#4

Please post a link to the exercise and below that, all of your code.


#5

https://www.codecademy.com/en/courses/javascript-beginner-en-x9DnD/0/6?curriculum_id=506324b3a7dffd00020bf661

// Check if the user is ready to play!
confirm ("Play?")
var age=prompt("whats your age");
if (age < 13)
{
console.log("you are too young")
}

else {
console.log("You are eligable lets go")
}

userAnswer = prompt("Will you race justin bieber?"); {
}
console.log ("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'")
if (userAnswer==="yes") {
console.log ("You and Bieber start racing. It's neck and neck! You win by a shoelace!")
}

if (userAnswer==="no") {
console.log ("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'")
}

else {
console.log ("error")
}

feedback = prompt("out of 10 how would you rate this game"); {
}
if(userAnswer>="8") {
console.log ("Thank you! We should race at the next concert!")
}
if (userAnswer<="7") {
console.log ("I'll keep practicing coding and racing.")
}


#6

Hmm. You defined userAnswer earlier in your code but I'm not sure how it's being evaluated against a text string("8"). Somehow, it fulfills the condition to print "Thank you! We should..." to the console. I'm stumped.


#7

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