Why is it Returning False When it Should Be True


#1



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


Why is it returning false? Shouldn't it be true? Because !programming === true, so the true === true inside the if statement will result to true. So then it should return true... right? My code is returning false.


// Declare your variables here!
programming = false;

var happy = function() {
  // Add your if/else statement here!
  if(!programming === true) {
        return true;  
    } else {
        return false;    
    }
};


#2

your function does return true, the false you see in the console is the value of programming (the codecademy console logs it for some obscure reason)

However, you function never executes because you don't call it:

happy();

functions only execute when called. If you execute your function you should see true in the console


#3

Cool. Maybe it would be better to include calling the function happy() as part of the instruction.

Thanks bro :smile: