Not!


#1

The logical operator not is written in JavaScript like this: !. It makes true expressions false, and vice-versa.

!true; // => false
!false; // => true
Instructions
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.
//// Declare your variables here!
var programming = false;

var happy = function() {
// Add your if/else statement here!
if (programming = false){ return true;}
else return false;
};
this is what i had written and ive also had countless other ways, im just not sure what to do


#2

programming = false

remember how comparison operators work.

1 equals sign is an assignment. "programming is false"

2-3 equals signs are a comparison. "programming is equal to false"

programming == false

try that.


#3

If you want to use the method using "Not" you have to write:
var programming= false;

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

};

The "!" turns the variable "programming" true


#4

I find it easiest to process if you read it out-loud.

The answer is written as follows:

var programming = false;

var happy = function() {
  if (!programming) {  //If programming is not(!) = to true (it's false, so this is true)
      return true;
  } else {
      return false;
  }
};

I commented inside of it to make it a bit easier to follow, but remember that if I were to write if (programming) that actually is short-hand for if (programming === true). What we're doing here is saying that if programming is **NOT** (!) === to true return true.

It's definitely a bit confusing at first, but try and read it out loud by saying not when see an exclamation (!) and see fi that helps make it more clear.