What is wrong here pls?


#1

The program says
Declare a variable called programming and set it to false. Then, write an if/else statement inside happy so that happy returns true if programming is false and false otherwise.

I did exactly the same but its giving me error why?
here is my code

var programming = false;

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

#2

We can negate a variable (toggle its Boolean state) with the ! operator:

if ( !programming ) {

It is true that !false is true, but programming is set to false so a comparison would still yield false if written this way:

if ( programming === !false )

or

if ( programming !== false )

By toggling the variable itself, the yield is true. Starting to make sense?


#3

In your if condition you should put === between programming and !false


#4

Hi,

You have to invoke the function at the end of the function and !false is not a operator.

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

I hope this helps :smile:


#5

Thanks so much i forget the simple details to closing