Functions & if/else


#1

// Write your function below.
// Don't forget to call your function!
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));
console.log(sleepCheck(5)):
console.log(sleepCheck(8));

This is my code but it keeps saying that there is a problem with my syntax


#2

There is one open curly bracket for the function definition, and one that closes it. That means the function definition ends here.
I think you meant to close the if clause, but forgot to open it.


#3

I don't understand.. Where does it go??


#4

Put one curly bracket after if (numHours >= 8)


#5

im have the same problem with my code is it a bug or something? if there is really something wrong with my code can you let me know.


#6

if(numHours >= 8) ; // remove ; and add {

now you have to close the function after closing else statement

syntax:

 if( condition){

  //comment  somthing
 }
 else{

   //somthing else
 }

#7

I Really Thank you from the bottom of my heart.