Been stuck for an hour #12 if/else


#1

I cannot figure out what I am doing wrong with this code. Please Help

my code:
// Write your function below.
// Don't forget to call your function!
var sleepCheck = function(numHours)
if(sleepCheck >=8){
return "You're getting plenty of sleep! Maybe even too much!";
}
else if (sleepCheck < 8) {
return "Get some more shut eye
}
console.log(sleepCheck(10));
console.log(sleepCheck(5));
console.log(sleepCheck(8));


#2

In what way is it misbehaving?


#3

"opps try again" There was a problem with your syntax
is the error I am getting


#4

Since there's not that much code you could attempt to stare it down.
You can also run it in some other environment that offers more verbose error messages, for example if I run it on my computer with node.js I get:

$ node tadkinszipwilm.js 

/tmp/tadkinszipwilm.js:4
if(sleepCheck >=8){
^^
SyntaxError: Unexpected token if

Which is saying that based on what has been read so far, if can't be there, there's something above causing if not to be allowed in this situation


#5

I rekeyed the entire code as:

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));
console.log(sleepCheck(5));
console.log(sleepCheck(8));

And got it correct.
Thanks!!


Stuck up for for 2 hrs #12 if/else