Skip to content

Latest commit

 

History

History
38 lines (28 loc) · 731 Bytes

_2626. Array Reduce Transformation.md

File metadata and controls

38 lines (28 loc) · 731 Bytes

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : July 09, 2024

Last updated : July 09, 2024


Related Topics : N/A

Acceptance Rate : 84.99 %


Solutions

JavaScript

/**
 * @param {number[]} nums
 * @param {Function} fn
 * @param {number} init
 * @return {number}
 */
var reduce = function(nums, fn, init) {
    nums.forEach(num => init = fn(init, num));
    return init;
};