Stuck really bad with #13


#1

This is the first exercise that has straight up gone right over my head.

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

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

The directions say: Declare a variable called programming and set it to false. Then, write an if/else statement inside happy so that happy returns true if programming is false and false otherwise.

I don't get this at all? In my code I declared a variable. Set it equal to false. And my if else statement definitely returns true if programming is false. But I don't really get where I'm supposed to use the "not" function in here, or really understand why I'd ever use it.


#2

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

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

I did this and it passed me. But I literally feel like I cheesed the assignment


#3

Well the not operator ! works like this:

!true -> false 
!false -> true

so if you ask for is true you could as well ask for not false.


#4

That doesn't make sense to me. Why not just ask for true? What advantage does this provide?


#5

It's ok and it works as it should but the exercise is to see the not operator in action so it would make sense to use it. Also the not operator is neat because it lets you flip the value of a boolean which might come handy when you don't want to assign a particular value but just want to make sure that it changes its value. Or if you just want to make sure that it has any but not this value.


#6

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

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


#7

!programming can be used in the if () and rest is all same