Lesson 12 . Function if/else


#1


Functions and if/else

with the correct console messages appearing in script editor, but keep receiving error message

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.

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));


#2

Hi on this line

    return "You're getting plenty of sleep! Maybe even too much";

it's missing the ! after much


#3

returing string need to be an exact match.

you missed a !


#4

Thanks very much! didn't realise needed an exact match of text in alert


#5

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