Understanding Switch Case and If-Else In Javascript

Which One Is Better and Why?

Otutu Chidinma Janefrances

--

Photo by Arturo Esparza on Unsplash

Should you use a switch case or an if-else statement?

if-else Statement

Determine the Season

const month = 7;

if (month >= 3 && month <= 5) {
console.log("Spring");
} else if (month >= 6 && month <= 8) {
console.log("Summer");
} else if…

--

--