EASY javascript solution || Beat 100% run-time || O(n)
Intuition\nWe are reusing the returned value from fn(init,nums[i]). \n\n# Complexity\n- Time complexity:\nO(n)\n\n# Code\n\nvar reduce = function(nums, fn, init
# Intuition\nWe are reusing the returned value from fn(init,nums[i]). \n\n# Complexity\n- Time complexity:\nO(n)\n\n# Code\n```\nvar reduce = function(nums, fn, init) {\n    if(nums.length==0) return init;\n    for(let i = 0;i<nums.length;i++) {\n        init = fn(init,nums[i])\n    }\n    return init;\n};\n```\nUPVOTE IF IT HELPS \uD83D\uDE03
['JavaScript']