Sleepcheck() function


#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!”;
}
}
sleepCheck(10);
sleepCheck(5);
sleepCheck(8);

This code only returns the answer for sleepCheck(10);
and left the other called function.
does this mean i can’t call a function more than once in a row.


#2

it’s just showing the last returning value.

you need to call the function with console.log() so that it prints the returning value.

console.log(sleepCheck(10));


#3

will it work if i use console.log() inside the function instead of return


#4

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