leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

2626.js (224B)


      1 /**
      2  * @param {number[]} nums
      3  * @param {Function} fn
      4  * @param {number} init
      5  * @return {number}
      6  */
      7 
      8 var reduce = function(nums, fn, init) {
      9     let acc = init
     10     for(i in nums) acc = fn(acc, nums[i]);
     11     return acc;
     12 };