✅ Simple Easy 🔥JavaScript || 🔥TypeScript Solution || Begineer Friendly ✅
Code\nTypeScript []\ntype Fn = (accum: number, curr: number) => number\n\nfunction reduce(nums: number[], fn: Fn, init: number): number {\n    for (let i of num
# Code\n```TypeScript []\ntype Fn = (accum: number, curr: number) => number\n\nfunction reduce(nums: number[], fn: Fn, init: number): number {\n    for (let i of nums)\n        init = fn(init, i);\n    return init;\n};\n```\n```JavaScript []\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 (let i of nums)\n        init = fn(init, i);\n    return init;\n};\n```
['TypeScript', 'JavaScript']