Javascript Exercise #12


#1


Javascript Exercise #12


I don't know what is wrong with my code, in the Print Screen as you can see I have an alert message but I don't understand why... I tried with console log and without it to call the function and didn`t see the problem... because it is giving me the answer as you can see in the print screen...


Replace this line with your code. 
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));


#2

Should be:

if (numHours >= 8) {
        return ("You`re getting plenty of sleep! Maybe even too much!");

Instruction says to log "You`re getting plenty of sleep! Maybe even too much!"


#3

I corrected what @denys.matsevych suggested but still giving me the same message alert...


#4

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


#5

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

// try without console.log
sleepCheck(10);
sleepCheck(5);
sleepCheck(8);

#6

now the only difference is the result... I only have one print on the output


#7

Your code was correct from the beginning. I think it's a glitch. Try to refresh your browser or reset code and paste my code.


#8

did it as you suggested and it works, but the only difference that I saw between your code and mine is the spaces between parenthesis and curly brackets ... maybe as you said is a bug in the platform or I don't know maybe i did something wrong and I haven`t notice it...


#9


#10

I tried your code:


#11

as I said... maybe I did something wrong...


#12

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