Easiest Solution
 # Intuition  \n\n\n\n\n\n# Complexity\n- Time complexity:O(n)\n\n\n- Space complexity:O(1)\n\n\n# Code\n\n/**\n * @param {number[]} nums\n * @param {Function} 
<!-- # Intuition -->\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n<!-- # Approach -->\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:$$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\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    for(var i=0; i<nums.length; i++){\n        init = fn(init, nums[i]);\n    }\n    return init;\n};\n```\n\n---\n\n![Upvote.jpeg](https://assets.leetcode.com/users/images/6371bfb1-e4cd-42bb-8078-8faa1570f752_1699381855.2903202.jpeg)\n
['JavaScript']