Albeit instruction is not followed,the code is still correct


#1

Although below code is correct but i have a confusion with instructions,the instruction is to return true if programming was false and false for other way around,but isn't !programming=true? so what actually happened is,it returned true for !programming being true. :confused:

var programming=false;

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


#2

Hi It use The ! To change The value of prgramming To true

!true  --> false 
!false  ---> true 

#your variable 
var programming  = false;
console.log (!programming);

#Output 
true

So in this case

if(!programming)

The if statement is true and return true


#3

return !programming;   # true

It is that simple, and the author wanted to drive that point home. This lesson has all the hallmarks of confusion central. If you don't get this, then don't continue. You don't get it.


#4

thank you i got the notion of it now.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.