13/15 Not


#1

var programming=false;

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

  {
  return true;
  }

};

what is wrong here?


#2

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

}; happy();

question solved


#3

Alright, I see a few contradictions here so let's start with this.

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.

YOUR CODE

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; }

POSTED REGARDLESS OF ANSWERED QUESTION


#4

thanks for the feedback it helps


#5

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.


#6

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:

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

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

Should this work?


#7

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;
    }
};

#8

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¢


#11