If (if-else loop is shorter) {...
It turns out that it’s not only just architects who love minimalism, but JavaScript developers do too. :)
Check out another, shorter, way of writing the if-else loop.
It’s really useful to have a short loop that can be easily understood in just one line:
Sweet! Let’s eat some apples! First, here’s an example of some classic If-Else syntax:
Now, let’s write If-Else using a new, shorter method:
You can try both of these functions live at JSFiddle,
or below by clicking ‘Result: