Functions/If else


#1



// It keeps returning SyntaxError
var sleepCheck = function(numHours) {
    if numhours > 8{
    return("You're getting plenty of sleep, maybe even too much");
};
    else{ 
        return("You need to get some sleep");
    };
};
numHour = 5
numHour = 9


#2

should be inside (), like so if (numHour > 8) {}

if (condition) {
block of code to be executed if the condition is true
} else {
block of code to be executed if the condition is false
}

there are no semicolons inside if/else block.

and you are using

it should be one and the same name

and if you want to call the function with this var

write it like so sleepCheck(numHour);

and to be safe define it like this var numHour = 9;


#3

Thank You!!I have been trying to figure that out for like an hour


#4

You are welcome

I sent you a PM with jsBin example of sth similar.

It works but it is not the solution to this lesson