Created
October 16, 2020 19:30
-
-
Save karenying/fb0c0be4fb6c3d1e1b7b594b03d0bba8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const date = new Date(); | |
const currHour = date.getHours(); | |
let timeframe; | |
if (currHour >= 6 && currHour <= 11) { | |
timeframe = 'morning'; | |
} else if (currHour >= 12 && currHour <= 16) { | |
timeframe = 'afternoon'; | |
} else if (currHour >= 17 && currHour <= 20) { | |
timeframe = 'evening'; | |
} else { | |
timeframe = 'night'; | |
} | |
document.querySelector('#timeframe').innerHTML = timeframe; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment