If we use return in place of console.log and calling a funtion 3 timesbut output is only one?


#1


var sleepCheck=function(hours){
    if(hours>=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

Your return statements shouldn't have parentheses around the text.


#3

also after this correction output not effected


#4

hmmm, could I see a screenshot?


#5

I believe that the last line of code repeats in the codecademy console. If you wish to see the results of all the sleepCheck values, use console.log.

Ex:

console.log(sleepCheck(99));


#6

It does not matter if parens are used or not. This is not a problem.


#7

I didn't know that, probably because a use a language a lot that throws an error if I put parenthesis around my return statements. But I'm always glad to learn something new :slight_smile:


#8

I find parens to be redundant, given the string is delimited, already, but it is valid JS.


#9

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