12. Functions and if/else question


#1



Please help!
I've been stuck on 12. functions if/else for ages!
I've tried to copy what I did for number 8 but keep getting the following error message


https://www.codecademy.com/courses/javascript-beginner-en-6LzGd/2/4?curriculum_id=506324b3a7dffd00020bf661

Oops, try again. It looks like sleepCheck() isn't returning "You're getting plenty of sleep! Maybe even too much!" when numHours is 10. Check your if / else syntax and whether you're using the correct comparison operator.<do not remove the three backticks below>


#2

Hello @kscane,

can you please post your code so that I can analyse it and try to assist you.


#3

2 posts were split to a new topic: 12. It looks like sleepCheck() isn't returning "You're getting plenty of sleep!


#5

Here's my code

/ Write your function below.
// Don't forget to call your function!
var sleepCheck = function (numHours){
}

if (sleepCheck(10) >= 8) {
console.log ("You're getting plenty of sleep! Maybe even too much!");
} else {
console.log ("Get some more shut eye!");
}


#6

Hello @bartholomewallen,

You have closed your function too early. The line after your function name, there is a closing curly brace which effectively tells the function that is the end of the function. Move that curly brace to after your if ... else statement and add a semicolon after it. That should make your code work...


#7

Thanks
The code works now


#8

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