switch statements
If else statements are great for evaluating Boolean conditions. There are many things you can do with them, but in some cases, it is better to replace them with a switch statement. This is especially the case when evaluating more than four or five values.
We are going to see how switch statements can help us and what they look like. First, have a look at this if else statement:
if(activity === "Get up") {
console.log("It is 6:30AM");
} else if(activity === "Breakfast") {
console.log("It is 7:00AM");
} else if(activity === "Drive to work") {
console.log("It is 8:00AM");
} else if(activity === "Lunch") {
console.log("It is 12.00PM");
} else if(activity === "Drive home") {
console.log("It is 5:00PM")
} else if(activity === "Dinner") {
console.log("It is 6:30PM");
}
It is determining what the time is based on what we...