Plzzzzzzz Help: Functions & if/else


#1

Can someone plzzzz tell me what I'm doing wrong? I have walked away and came back to this so many times. I'm so frustrated..uuugHH..wig shifted and all!!

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


#2

var sleepCheck = function(number);

the semi-colon on this line interrupts the function from working properly.

same here:

if(numHours >= 8);

except, here also a { is missing to mark the start of the if content.

and, numHours should have the same name as the function parameter, so change either one
and finally:

}
// missing } to close function
sleepCheck(10);

i hope i got them all


#3

I guess my brain is just not grasping anything tonight, still stuck!


#4

please post an updated version of your code?


#5

I just reset code, will update once I try again.


#6

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


#7

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


#8

var sleepCheck = function (numHours)
{
if(numHours >= 8)
// missing { to start if content
return "You're getting plenty of sleep! Maybe even too much!";
}; // remove semi-colon
else
{
return "Get some more shut eye!";
}; // remove semi-colon
// missing } to close function
sleepCheck(10);
sleepCheck(5);
sleepCheck(8);

see comments in code


#9

I so apologize, I finally solved it, it took me forever, but I got it. Thanks!


#10