What is the error ? 12.Functions & if/else


#1

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!";

}

};
var abc=sleepCheck(10);
console.log(abc);
var abd=sleepCheck(5);
console.log(abd);
var abe=sleepCheck(8);
console.log(abe);


#2

@bitrockstar18887,
Follow the Instructions:

  1. Inside the function, write an if statement where if the number of hours of sleep is greater than or equal to 8, the computer will
    return "You're getting plenty of sleep! Maybe even too much!";.

#3

But i already wrote those. :frowning: Still its not working


#4

Can you please copy paste ur entire code?


#5

@bitrockstar18887,
What about you displaying the code you are using..


#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!";

}

};
var abc=sleepCheck(10);
console.log(abc);
var abd=sleepCheck(5);
console.log(abd);
var abe=sleepCheck(8);
console.log(abe);


#7

@bitrockstar18887,
You will have to use the EXACT text's as are stated in the Instructions.....


#8

you don't have to put the var outside the function, just type sleepCheck(10); and so on.


#9

@nisapw,
But as your sleepCheck function
is using the return statement,
which will return a =result= with NOdisplay
you will have to use

console.log( sleepCheck(10) );

#10

I've got a similar problem. The console logs the correct output but the popup is to the contrary.
/
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));

That's the block. I'd appreciate all the help I can get!


#11

There must be a space between ...of sleep! Maybe even...


#14