Coding Tip: Try to Code Without If-statements
Samer Buna

…which opens the door for unique capabilities like modifying the code as it is being executed!

Well, I suppose I should thank you for bucking the trend of claiming that all data should be a Grail-quest for immutability so that we can “reason” about it, but other than lazy definition of code that calls DOM-management functions, I don’t see how mutable code makes an application easier to maintain and debug. (I refuse, other than for the purpose of writing something like this sentence, to use the phrase “reason about” because it’s clichéd and pretentious.) I get that Winograd used it to great effect in SHRDLU, but most of us aren’t writing SHRDLU.

Also, please:

arrayOfNumbers.forEach((number) => {
counter += Math.abs(number % 2);

Why visit the Land of Gratuitous Temporary Values when it adds nothing?

In fact:

let counter = arrayOfNumbers.reduce((acc, num) => 
acc + Math.abs(num % 2)

In situations like this, the argument to forEach can’t be a pure function, and the ARs are grousing about that at every available opportunity, too — usually right after mentioning immutable data.

Like what you read? Give Brook Monroe a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.