12/13 SyntaxError: Illegal return statement


#1

// Write your function below.
// Don't forget to call your function!

var sleepcheck= function(numHours){
return 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))

I'm not sure whats wrong but it keeps returning "SyntaxError: Illegal return statement"
Anyone know what the problem is?


#2

Hi @arraycoder18200 look code below


#3

It is returning like this "You're getting plenty of sleep! Maybe even too much!
undefined
Get some more shut eye!
undefined
You're getting plenty of sleep! Maybe even too much!
undefined
You're getting plenty of sleep! Maybe even too much!" and "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."


#4

Ok @arraycoder18200 try this

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(10);
sleepCheck(5);
sleepCheck(8);