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?
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?
var programming = false;
var happy = function() {
// Add your if/else statement here!
if (programming == !true) {
return true;
} else {
return false;
}
}; happy();
question solved
Alright, I see a few contradictions here so let’s start with this.
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) {...}
^
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
thanks for the feedback it helps
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:
// 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?
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;
}
};
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¢