I think I found a bug in the JavaScript course


#1


There's a bug in this exercise. If I Save & Submit this code, it gives me the error message: "Did you add an if statement to your code". But everything works, a prompt comes up, if I put in "yes" it does what it must do, and the same goes for "no"

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 {
    console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");
}


#2

can i have the link to the lesson please?


#3

#4

your code is fine.
i assume that you have code before this that asks the user for their age and you have an if statement that says you aren't responsible if they're under 13.
the age check is used in lessons 2 to 4 so maybe it got deleted?


#5

Ahh thank you very much, I did delete that code, I thought I wouldn't need it anymore


#6

Could you also tell me why this code doesn't work ? I need this for the same JavaScript course:

var orangeCost = function (price) {
    var value = price * 5;
    console.log(value);
};

orangeCost = 5

#7

This is not how you call on functions

You call on functions like


#8

Ahh thanks for your help


#9

Could you tell me why this if statemenrt doesn't work ?

var sleepCheck = function(numHours)
if(numHours >= 8) {
    return "You're getting plenty of sleep! Maybe even too much!"
}
else {
    return "Get some more shut eye!"
}
sleepCheck(10)

Nevermind, I see what I did wrong


#10

You aren't nesting the if statement inside the sleepCheck function, you have it just sitting off on it's own.


#11

@corecoder67987, fix this:

var sleepCheck = function(numHours) // {
    if(numHours >= 8) {
        return "You're getting plenty of sleep! Maybe even too much!" // ;
    }
    else {
        return "Get some more shut eye!" // ;
    }
 //  }
sleepCheck(10) // ;

I've tried to put comments where the errors are, and next to them I've put the character you need to put there.


#12

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