13. Guess I'm just confused


I don't get this. :confounded:

If I have something like this:

var programming = false;

var happy = function() {
    if (!programming){
        return true;
    } else {
        return false;

So it means !programming === true, right?

Shouldn't it return false if !programming?

Guess I'm just confused.

Exercise 13

As you have it, your code would return false.

The if-statement runs if it has a true condition.

The not ( ! ) operator reverses the value, which makes programming's reverse true.


Exactly. But it returns true!

I think I got this, though. I was having a hard time getting what the exercise asked.

Then, write an if/else statement inside happy so that happy returns true if programming is false and false otherwise.

I thought the variable would change from false to true just because I have ! before it, but what really changes is what if reads, right?


var programming=false;
var happy = function() {
if(programming!=true) //!=true is equal tp false
return true;
return false;