Last active
June 15, 2022 07:16
-
-
Save MultiMote/05d7f5a278043b24f776f114371ae660 to your computer and use it in GitHub Desktop.
Get season name from month
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 month = new Date().getMonth(); // 0-11 | |
const seasons = ['winter', 'spring', 'summer', 'autumn']; | |
const seasonIndex = Math.floor(((month + 1) % 12) / 3); | |
const seasonName = seasons[seasonIndex]; | |
console.log(seasonName); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment