What is the error in this code?


#1

// Write your function below. 
// Don't forget to call your function!
var sleepCheck=function(newHours)
    if(newHours>=8){
    return("you're getting plenty of sleep! Maybe even too much!");
    }
    else
    {
        return("Get some more shut eye!");
        }
    
sleepCheck(6);

#2

guess its numHours not newHours. But I guess the more important problem is that you forgot to wrap your function in {}:

Syntax

var name = function(){...};

#3

I corrected numhours but it is still showing some syntax errorr. Can you please help me out


#4

Have you fixed the missing { and } at the beginning and end of your function as well?


#5

// 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!");
    }

sleepCheck(6);

Thisis my latest code. dont know what is wrong.
I have written {...}


#6

// Write your function below. 
// Don't forget to call your function!
var sleepCheck=function(numHours){ // one at the beginning of the function
    if(numHours>=8){

return("you're getting plenty of sleep! Maybe even too much!");
}

   else

  {  return("Get some more shut eye!");
    }
}; // one at the end of it
sleepCheck(6);