Javascript - Write program to fix if else statement

Requirements

Write program to fix if else statement

The if/else statement does not work.

var greeting;
var hour = new Date().getHours();

if (hour < 18) {
    greeting = "Good day";
else
    greeting = "Good evening";
}

console.log( greeting );

Hint

Some curly braces are missing.

Demo

var greeting;
var hour = new Date().getHours();

if (hour < 18) {
    greeting = "Good day";
} else {//  w  w w .java  2s  .c  o  m
    greeting = "Good evening";
}

console.log( greeting );

Result