# 13/15 Not

var programming=false;

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

``````  {
return true;
}
``````

};

what is wrong here?

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

}; happy();

question solved

1 Like

# Problem:

The layout of a function is as follows.

``````var happy = function() {...};
``````

The way youâ€™re doing it (listed below) is not correct grammar for the function.

``````var happy = (function) {...};
``````

The second Problem I am seeing here is with your IF statements.

``````if (happy=!false) {...}
^
``````

and

``````else/if(programming=!true) {...}
^
``````

### PROPER GRAMMAR:

``````if (happy == !false) { return true; }
// Remember this statement is the OPPOSITE of false
``````

If you wanted to have an â€śelse ifâ€ť statement. Itâ€™s formatted as such.

``````else if(programming == !true) { return false; }
``````

thanks for the feedback it helps

1 Like

This is pretzel logic, when we get down to it. `happy` is defined as a Boolean so needs no comparison, just a conditionalâ€¦

``````if (happy) { // do something for true }
else { // default }
``````

If our goal is to determine that one operand is not the same as another, then we should use the `not equal to` operatorâ€¦

``````if (a !== b) { // }
``````

A conditional always yields a Boolean, regardless the expression or data type of the operands. When the conditional argument is already a Boolean, then as shown above, no comparison necessary.

Totally confusedâ€¦
Tried all the methods above, didnâ€™t seem to work so I tinkered around with the true and falses (desperation lol)

This worked for me:

var programming = false;

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

Should this work?

We are setting `programming` to a Boolean primitive, `false`,

``````var programming = false;
``````

Next we want to test if its negated state is `true`â€¦

``````if (!programming) {
// will return true
}
``````

Putting this into a function we have,

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

Am I reading it wrong? Or does the correct answer read â€śif not programming; happy = true.â€ť To be commensurate with everything else, shouldnâ€™t that be made to read â€śif not programming; happy = false.â€ť Or perhaps â€śif not programming; unhappy = true.â€ť Just seems backwards to me given this is a coding tutorial site.
just my 5Â˘

1 Like