Easy and simple approach!!
\n\n# Code\n\n/**\n * @param {number[]} nums\n * @param {Function} fn\n * @param {number} init\n * @return {number}\n */\nvar reduce = function(nums, fn, init) 
\n\n# Code\n```\n/**\n * @param {number[]} nums\n * @param {Function} fn\n * @param {number} init\n * @return {number}\n */\nvar reduce = function(nums, fn, init) {\n    var ans=init;\n    for(var i=0; i<nums.length; i++){\n        ans=fn(ans, nums[i]);\n    }\n    return ans;\n};\n```
['JavaScript']