Lesson 12 if/else functions


#1



When I press Save & Submit Code, it tells me that there is a syntax error.


 // 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!";
    }
    sleepCheck(8);


#2

There's not that much code there, have you read through it carefully?

Note that you're ending an indented block without a }, that definitely isn't right. How come that's omitted? And are there any other similar problems?


#3

I wish they made it easier to respond by cutting and pasting my code out of the lesson, but for some reason I can't copy any of my code. I'll tell you what I see though

you have the following on your second line
if(numHours >= 8) }

do not put that } in that location. You need to move it all the way to the end. The if/else function is entirely inside the sleepCheck function so you need to wrap the whole thing in { }

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!";
}
}
sleepCheck(8);


#4

You aren't closing out your var function with

};

at the very end of the code (right above when you call sleepChcek


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.