If/else syntax error


#1

i think i did this right but it keeps saying
Oops, try again. It looks like your function doesn't return "Get some more shut eye!" when numHours is 5. Check your if / else syntax and whether you're using the correct comparison operator.

i don't know whats wrong please check my code

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


#2

it looks like you didn't close one of your braces where it says
"var sleepCheck = function (numHours) {" do you see what I mean?


#3

thank you so much i have been stuck on this :smile:


#4

wait it still dosnt work :hushed:


#5

thats odd I thought that would fix it


#6

what error does it say that you have?


#7

it says the same thing and i actually DID close the curly brace


#8

are you sure you need the curly braces?


#9

yes i take them away it says i have a syntax error


#10

i'm sorry to say I'm not sure whats wrong


#11

its ok :wink: thanks for trying


#12

you need to pass the different hours in like so

else {
return "get some more shut eye!";
} }
sleepCheck(10);
sleepCheck(8);
sleepCheck(5);


#13

From the error message I'd say that you need to write the else phrase with a starting capital "G". Anyway the syntax seems to be ok so just check your sentences closely on typos or just copy and paste the messages from the instruction. Good Luck!