A Better Way to Write Lengthy Multiple `OR` Conditions
When working with JavaScript, we deal a lot with conditionals, here is a quick and easy way to write better / cleaner multiple or conditionals. Let’s take a look at the example below: // condition function test(fruit) { if (fruit == 'apple' || fruit == 'strawberry') { console.log('red'); } } Initially, the example above appears to be a good one. However, what if we received more red fruits, such as cherries and cranberries?...