Time flies while you're having fun, but then one day your bio says something about being a 30+ year veteran in software engineering. Still, I've not seen it all, let alone done it all (yet).
Nice article. Building an intuition for overly complex code is really essential. Often when working on code, there comes that moment when you hack things around to get things working. Its essential to refactor until its been simplified.
Some tool chains can calculate code metrics for you, and Cyclomatic Complexity is very relevant here.
Finally, some languages have support for pattern matching, which can really improve things here. Sorry, I'm not current on Javascript, but your example could be expressed in C# 8 like this;
Nice article. Building an intuition for overly complex code is really essential. Often when working on code, there comes that moment when you hack things around to get things working. Its essential to refactor until its been simplified.
Some tool chains can calculate code metrics for you, and Cyclomatic Complexity is very relevant here.
Finally, some languages have support for pattern matching, which can really improve things here. Sorry, I'm not current on Javascript, but your example could be expressed in C# 8 like this;
(You don't strictly need to unpack the tuple, but its more readable)
Thank you! Really interesting inputs in your comment. Thank you for sharing 🙏
Pattern matching can be (sort of) simulated in languages supporting switch cases. I find it very readable.