13. Guess I'm just confused


#1

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
#2

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.


#3

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?


#4

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