12. Functions & if / else/ " There was a problem with your syntax."



I wonder what's wrong with my code. It says: Oops, try again. There was a problem with your syntax. And in the black window it prints: SyntaxError: expected expression, got keyword '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!");}




You need to put a { and then put a }; after your last return statement.

Also you need to call your sleepcheck function inside a console.log

for example console.log(sleepCheck(10));


Ok, now it works properly :slightly_smiling: