nick34992
3/14/2017 - 11:20 PM

JavaScript Console: Good Morning, Good Afternoon, Good Evening

JavaScript Console: Good Morning, Good Afternoon, Good Evening

var currentTime = new Date();
currentTime.getHours();
var currentHour = currentTime.getHours();
switch (true) {
    case (currentHour < 12):
        console.log("Good morning!");
        break;
    case (currentHour > 12 && currentHour < 17):
        console.log("Good afternoon!");
        break;
    default:
        console.log("Good evening!");
        break;
}