Functions & if/else


I have read other posts and it still doesn't seem to work. Any assistance?

// 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!";
return "Get some more shut eye!";
console.log (sleepCheck(10));


You have a semicolon on the } of your else which should not be there. And you're missing the }; to close the function.


That worked!

Thanks so much.


I had the same problem - not closing the function....

I'm wondering if if you need to put () for the statement e.g is return ("bla bla") the same as return "bla bla" ... because it doesn't seem to make a difference but I always thought you had to use ().



return is a keyword and not a function so the () are not necessary. But you can almost everywhere add () then they work like the parentheses in math 2*(3+4). But as there is mostly only one value after return that is not necessary and too many () to cope is probably more confusing than helpful.