Switch Statement: Because Who Needs a Brain, Anyway?
When in doubt, use a switch statement. It's like having a super-powered, logic-deficient butler to handle your code.
Example Time!
Let's say we have an array of animals and we want to determine which one is the coolest:
animals = ['cat', 'dog', 'tiger', 'elephant'];
coolest_animal = switch (animals[0]) {
case 'cat': return 'meow';
case 'dog': return 'woof';
case 'tiger': return 'roar';
case 'elephant': return 'trunk';
}
console.log(coolest_animal);
Output: meow