12. Functions if and else


#1

Hello guys, i simply don't find my error.
Can you help me?
The machine says:

> SyntaxError: Unexpected token else

// 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));

#2

your if has two closing curly brackets (}), it should just be the one


#3

Thank you. But it doesn't helped much.

SyntaxError: Unexpected token )

// 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

it solved the problem you had, so that is good. Did you take a moment to take a look what caused this new error? Hint, it again has to do with (too many) brackets, and it is in the last line

I always solve one problem at a time, if a new problem arises, the learner has the opportunity to find and solve it themselves (good for there debug skills)


#5

Thank you very much. Found it. Too dumb too see it :frowning:
The hint was awesome