Functions 12: Only calls function once


#1


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


The function only prints out the last time that I called it. I would expect it to print the first string, then skip a line and print the second string, then skip a line and print the first one again, corresponding to the three times the function was called and the varying numbers passed into the function. What would make this happen?


function sleepCheck(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);


#2

to log something to the console you should console.log(), so you could call console.log() on sleepCheck(10) to log to the console what the function returns


#3

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