12. Syntax Error


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

I think I’m being really stupid but I can’t work out what my syntax error is, it says its an unexpected token (
<Below this line, add a link to the EXACT exercise that you are stuck at.>
12.

<In what way does your code behave incorrectly? Include ALL error messages.>

``` var sleepCheck(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));
console.log(sleepCheck(5));
console.log(sleepCheck(8));
<do not remove the three backticks above>

#2

Depending on your background this might not look straightforward - What you’re trying to do is define a function. This is achieved with the function keyword. var is mostly used for variables. Change your var into function :wink:


#3

Hi you should declare your function like that

var sleepCheck = function() {
 #here go your if  and else statement 
}

#4

Thanks, as soon as you said that it stuck out like a sore thumb! Nightmare! :slight_smile: