Javascript - Write program to Add an else statement to if.

Requirements

Add an else statement to display "You're not John!".

var firstName = "Json";

if (firstName === "John") {
    console.log( "Hello John!" );
}//your code here

Hint

if (condition) {
   block of code to be executed if the condition is true
} else {
   block of code to be executed if the condition is false
}

Demo

var firstName = "Json";

if (firstName === "John") {
    console.log( "Hello John!");
} else {/* w  w w.  ja  v a2  s .co m*/
    console.log( "You're not John!" );
}

Result