Playing with CODES (Whole exercise)


#1

Hi people! Has anyone play with the codes in all exercises?
I've tried it but it seems like the outcome is not correct.

For example in the part where you ask the user answer

I tried both "=" and "==="

If i use ( userAnswer = "Yes")

the outcome is always the if statement

If i use ( userAnswer === "Yes")
the outcome is always the else statement

as well as the feedback code. It always gives me the else statement

PS If my code is incorrect please let me know

confirm("Are you ready to play?");// Check if the user is ready to play!
var age = prompt ("What's your age?");
if ( age < 13){
    console.log("You are allowed to play but programmer will not take any responsibility");
}
else {
    console.log("Let me see what you got!");
}
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 = ("Do you want to race Bieber on stage?");
prompt(userAnswer);
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.'");}
var feedback = "How's your experience?"
prompt(feedback)
if ( feedback >= 8){
    console.log("Thank you! We should race at the next concert!");}
else{
    console.log("I'll keep practicing coding and racing.");}


#2

You forgot a closing parentheses and colon in your first if statement );.

Also In your userAnswer variable it would be easier and less work for you to just write var userAnswer = prompt("Do you want to race Bieber on stage?");
Instead of
var userAnswer = ("Do you want to race Bieber on stage?");
prompt(userAnswer);

And also the same for your feedback variable. Try var feedback = prompt("How's your experience?");
Instead of
var feedback = "How's your experience?"
prompt(feedback) cause you also forgot to put a ; after prompt(feedback).


#3

Hi bandit!

I've tried using those however the result still the same. Nothing new :confounded:


#4

Take a look at how my code looks from the userAnswer variable.

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.'")
}
var feedback = prompt("On a scale of 1 to 10 please rate this scenario")
if (feedback >= 8)
{
    console.log("Thank you we should race at the next concert!")
}
else {
    console.log("I'll keep practicing coding and racing")
}

#5

@jezzrael after the prompt("Do you want to race Bieber on stage?") comes up, are you capitalizing "Yes"?

also check your if (feedback >=8) to see if it is what the instructions are asking for.


#6

I debugged all my code later on i used the **||** operator to account for 'yes' or 'Yes' and instead of if's I used a switch statement