12. Function & if/else


#1

I have tried a bunch of different things. This is how i originally wrote the code so I reverted back to it. I can't seem to figure this out thanks in advance


https://www.codecademy.com/en/courses/javascript-beginner-en-6LzGd/2/4?curriculum_id=506324b3a7dffd00020bf661#

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 pleny of sleep! Maybe even too much!";
}
else
{
    return "Get some more shut eye!";
}
};
sleepCheck(10);
sleepCheck(5);
sleepCheck(8);


#2

pleny should be plenty


#3

hahaha jesus only took me an hour to spot that just found it before you commented but thankyou


#4

var Sleepcheck = function (numHours);
{
if (numbHours >= 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);

What went wrong? thanks!


#5

numbHours or numHours?


#6

...lol ok, i'd just changed to numHours. still doesn't work.


#7

I think 'numb' reflects to the condition of my eyes


#8

var Sleepcheck or sleepCheck?

Also, remove the semicolon on the 1st line.

:laughing:


#9

thanks. I fixed both, still doesn't run...


#10

Got it! Thanks! It was very helpful.


#11

How were you able to make it run, I can't get it to run

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


#12

maybe should be Maybe


#13

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