12.Functions & if/else


var sleepCheck = function(numHours){
if(number of hours of sleep >= 8){
return "You're getting plenty of sleep! Maybe even too much!";
else {
return "Get some more shut eye!";


what's wrong in it? i can't find....please help...


This worked for me:

// Write your function below. 
// Don't forget to call your function!
function sleepCheck(numHours){
if (numHours >= 8) {
  console.log("You're getting plenty of sleep! Maybe even too much!");
} else if (numHours < 8) {
  console.log("Get some shut eye!");
console.log("You sleep a lot boi!");
console.log("Sleep more.");
console.log("Just average, but good.")};

It seems like you need to understand functions, formatting and indentation more, at the least. :slight_smile:


The left side of your if condition should be a variable. Is this all of your code or is there a confirm or prompt statement on a preceding line?


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.