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 );
Some curly braces are missing.
var greeting; var hour = new Date().getHours(); if (hour < 18) { greeting = "Good day"; } else {/*from w ww. j ava2 s.com*/ greeting = "Good evening"; } console.log( greeting );