Algorithms 101: Happy Number in JavaScript

added by JavaScript Kicks
10/18/2019 8:16:26 AM

96 Views

In the code above, array.reduce() takes a callback function. This callback sets the sum to an initial value of zero. Then it loops over every item in the array, In the first loop, it adds currentItem to the initial value, 0. It stores the sum in accumulator.


0 comments