Functions and if /else


Replace this line with your code.

var sleepCheck = function(numHours) {
if ( numHours >=8)
return " bla bla";
else {
return " blahhhhhhhhh";
why is this wrong?


First things first, what is it doing differently from what you want? "Wrong" doesn't describe that!


The compiler says, "Check your if/else statement and whether i have used correct comparators or not, plus it says," That i am not getting the output of 'if' statement when the "numHours" is 10.


That's something codecademy says, not the interpreter!

Is it saying you should be printing something? You're not, are you? How can you change that?
(No clue what the instructions really say but you mention "output" so perhaps that means printing, not return value, you'll have to refer to the instructions for how it should behave)


Thanks, now i know js is interpreted not compiled.
I corrected it myself, the problem was with the output,each alphabet was supposed to be what it is mentioned in the instruction.


Well it's both, those are really vague terms and to some extent all languages do both, but from a user stand-point we are feeding code to a program that executes it for us, as opposed to generating an executable binary file.
Modern JS interpreters go to great lengths to speed up execution, and it does involve generating machine code.


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