Stuck on a lesson. Need a code check please!


#1

I'm stuck on lesson 12. Functions & if/else (within Introduction to Functions in JS)

This is the error I'm receiving: "SyntaxError: Unexpected token else"


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!";
    };
};
console.log(sleepCheck(10))
console.log(sleepCheck(5))
console.log(sleepCheck(8))


#2

You may find this link useful :slight_smile:

https://www.codecademy.com/blog/78-your-guide-to-semicolons-in-javascript


#3

I'm stuck at the same lesson but it keeps telling me it doesn't return the right string... Anyone can help? thanks.

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

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";    
    }
};

console.log( sleepCheck(10) );
console.log( sleepCheck(5) );
console.log( sleepCheck(8) );

#4

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