Please checkout my code


#1



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


Oops, try again. There was a problem with your syntax.


// Write your function below. 
// Don't forget to call your function!
var sleepCheck = function (numHours) {
        if (var numHours = 0; numHours >= 8) {
    return "You're getting plenty of sleep! Maybe even too much!";
} else {
    return "Get some more shut eye!";
}};
    sleepCheck(5);
    //console.log(           //incomplete code, because i am confused about it.


#2

this is about all over the place, you don't need to declare numHours as a variable because its function(numHours)

It looks like you've got the start of a loop there but it's not needed at all.

if(numHours >= 8) {

also use console.log(sleepCheck(5)); if you want something to print to the console.


#3

It works really like a charm ,Thank you so much for your quick correction, actually i am little confuse in if/else, for/loop logic want more of it, please guide me, and Thankyou once again, catch you later!


#4

Okay I'll give it best to explain it:
I'll start with an if and else.

var happy = true;

if(happy === true) {<!-- In here you have what you're comparing, so for me I'm seeing if happy is true --> 
console.log("It's good that you're happy"); <!-- this will print if happy is true --> 
}else{ <!-- otherwise do this, else cannot compare anything, it's default. If I can't do any of the others then do this -->
console.log("thats too bad"); <!-- this will print if it if happy isn't true. -->
}

And here's a for loop

for(var i = 0; i < 21; i++) { <!-- counts up from 0 to 21 incrementing by 1 each time -->
 if(i % 5 === 0) {   <!-- checks if i is divisible by 5 -->
   console.log("that is divisible by 5"); <!-- if it is print this -->
} else if(i % 2 === 0) { <!--- otherwise if i is divisible by 2 -->
  console.log("That is divisible by 2"); <!-- print this instead -->
}else{ <!-- adding our default case if it's not divisible by 2 or 5 -->
  console.log(i); <!-- prints the number it's on -->
}
};

#5

Thank you i am working on it and practicing as much as i can to better understand and grip on it.
Actually i am from networking and VOIP background but i really want to learn Node.js, that's why i am starting the beginners course over here to make my base and foundation getting right, its a long way to go but i want to go step-by-step. Thanks