Already pass but dont understand


#1

var programming=false;

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

}
else { return false ;}
};

i dont understand why need to use !false ( example var ) and why my code screen are blank ?


#2

We use the ! character to represent the opposite. In English, we might say "not", when reading our condition. Reading your code:

if not programming (false), return true, else, return false.


Since we have the variable programming set to false, the opposite of it would be true. So, removing the variable from that sentence, we get this:

if not false, return true, else, return false


And to make it even easier to understand:

if true, return true, else, return false


It's a bit of work, but eventually we get the desired result.


#3

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