12 Function if/ else


#1

It looks like sleepCheck() isn't returning "You're getting plenty of sleep! Maybe even too much!" when numHours is 10. Check your if / else syntax and whether you're using the correct comparison operator.

// Write your function below. 
// Don't forget to call your function!

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


#2

You need to have You're not Your're! Common mistake :smiley:

Note: I always suggest in these lessons that have direct copying that needs to be done for long strings like in Code Your Own Adventures just to copy and paste it from the instructions to avoid mistakes


#3

I made sure that I did "You're" and it still isn't working!

"It looks like sleepCheck() isn't returning "You're getting plenty of sleep! Maybe even too much!" when numHours is 10. Check your if / else syntax and whether you're using the correct comparison operator."

// Write your function below.
// Don't forget to call your function!

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

sleepCheck(10)
sleepCheck(5)
sleepCheck(8)


#4

Might be because you misspelled getting as gettting? Looks to be the only typo as far as I can tell


#5

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