12 Function & if/else


#1


https://www.codecademy.com/en/courses/javascript-beginner-en-6LzGd/2/4?curriculum_id=506324b3a7dffd00020bf661#


SyntaxError: Unexpected token if


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


#2

You seem to have forgotten your "{}"s after the 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!";
    }
}

#3

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