Just curious, why did I have to call this function with console.log if it wasn't necessary in some of the previous exercises


#1



// Write your function below. 
// Don't forget to call your function!

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

Replace this line with your code.


#2

It is so the return value gets printed to the display.


#3

Thanks so basically if there was no return value I could call it by simply writing sleepCheck();?


#4

The function can be run without logging the return value, yes.

var five_hours = sleepCheck(10);
console.log(five_hours);         // Get some more shut eye!

#5

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