Monday, May 8, 2023

123: JS Challenge 4

 Today's challenge involved transforming an array. Leetcode asked you to write a function that accepts an array and a transform function, and return an array who's elements have all been transformed accordingly. In my opinion the cleanest way to do this is with the Array.map() method. The map method is passed a function, which is applied to each element of the array. The problem can be solved in a single line of code, with "return arr.map(fn)"

No comments:

Post a Comment

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...