Today's challenge was to hand-write a function that reduces an array. This function accepts a callback function and applies it to the elements of the array, and combines them into an accumulator variable. I accomplished this by declaring a variable, iterating over the array with a (for, of) loop, and summing their values into the accumulator to return. The built-in array method to achieve this is called Array.reduce. Reduce is a powerful method that can combine the functionality of both filter() and map().
Subscribe to:
Post Comments (Atom)
190: Sablier
The CodeHawks platform has an upcoming audit on the Sablier protocol, so I decided to read through the docs and familiarize myself with the...
-
The CodeHawks platform has an upcoming audit on the Sablier protocol, so I decided to read through the docs and familiarize myself with the...
-
The ZKasino project recently exit scammed over 33 million dollars worth of Ethereum. he recent debacle surrounding ZKasino offers valuable...
-
In addition to its native SDK, Hedera also supports smart contracts in a platform compatible with the Ethereum Virtual Machine. This allows ...
No comments:
Post a Comment