12. Functions & if/else - Help!


#1

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

Oops, try again.There was a problem with yur syntax.


#2

the condition of your if statement should have brackets:

if (condition){

#3

@lesteri16
As @stetim94 wrote, you missed brackets in if.
You forgot about curly bracket after function keyword and you should close it at end of function.

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

It should looks like:

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

Also semicolon isn't mandatory after an if statement.


#4

Thank you very much it worked!!!!