13 Not


#1


https://www.codecademy.com/courses/javascript-beginner-en-qDwp0/2/4?curriculum_id=506324b3a7dffd00020bf661#


It keeps saying else or my syntax is unexpected:

SyntaxError: Unexpected token else


// Declare your variables here!
var programming = false 

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


#2

I re-indented your code to better match what is being said

// Declare your variables here!
var programming = false

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

#3

if () {

} else {

}

No punctuation on the structure, just statements contained within the blocks.

Comparison uses ===.

The NOT operator negates a boolean. NOT true is false. NOT false is true.

It's also good to know that it will convert a non-boolean to a boolean then negate it..

!("A") => false

!(0)   => true

#4

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