Better use of syntax in if else statement to choose season based on a variable

Viewed 17

I'm using an else if statement to tell me the current season (In the Southern Hemisphere)

const MONTH = 'March'

if (MONTH == 'December'|| MONTH == 'January'|| MONTH == 'February'){
   console.log('Summer')
}
else if (MONTH == 'March'|| MONTH == 'April'|| MONTH == 'May'){
  console.log('Autumn')
}
else if (MONTH == 'June'|| MONTH == 'July'|| MONTH == 'August'){
  console.log('Winter')
}
else console.log('Spring')

While this works, the repeated use of MONTH is not a great way to go about it.

What would be a better way to write this code, still using an if else statement?

0 Answers
Related