Help in #13 Not!


#1

I just cant figure this out. Can some help?

// Declare your variables here!
var programming = false;

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

};

#2

You have the correct code, along with some extra that can be removed.

if (!programming) { ...

#3

You don't have to use the OR operator here. Just follow the examples shown:

!true;   // => false
!false;  // => true

This was my answer:

    var programming = false

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

#4

Technically, we do not have to use an equality operator, either. It is not a good practice to write:

== !true

It should be a non-equality or a non-identity:

!= true
!== true

But this is moot. Since programming is a Boolean (false) we can use just the line above that I wrote in the previous reply.

if (!programming)

Remember that no matter what we type into a conditional expression, it yields a Boolean. If it already is one, then there is no work to be done.

if (expression) {
    // this branch
} else {
    // this branch
}

An expression can be anything that is not a statement. Some examples of expressions are as follows:

"a string"  // string expression
6 * 7       // numerical expression
foo(){}     // a function expression
a && b      // a logical expression
a < b       // a comparison expression
a === b     // an identity expression
1 == "1"    // an equality expression

and so on.


#5

Thanks for the rundown. It helped me understand how to use the = properly. :thumbsup:


#6

I see what you mean about skipping the equality operator. Much more direct.

(For some reason somehow I didn't think you could stick the ! operator in front of programming, just hadn't seen many instances of that.)

Anyway so I rewrote it more simply:

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

Thanks for your tips!