Functions & if/else syntax error


#1

Continuing the discussion from Syntax Error:

Also getting a syntax error:
// Write your function below.
// Don't forget to call your function!
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

Nevermind, I didn't have parenthesis around the if statement


#3

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

SyntaxError: Unexpected token else

I have been staring at this and can't seem to figure out the issue. Please help!


#4

Put curly brackets in, like so:

if (numHours >= 8){
return "You're getting plenty of sleep! Maybe even too much!";

#5

Error, output = "[Function]"
check this screenshot!


#6

Remove the space between function and (numHours).


#7

Thank You @jibblyj - character limit :smile:


#8

please help me..i really don't see where i wrong :sweat: