Skip to content

LeetCode

Function Composition - 2629

Function Composition – 2629

🔗LC2629 🟢 Easy 🧩 Pattern – Function Transformations 📅 Day 8/30 Days of JavaScript Given an array of functions [f1, f2, f3, …, fn], return a new function fn that is the function composition of the array of functions. The function composition of [f(x), g(x), h(x)] is fn(x) = f(g(h(x))). The function composition of an empty list of functions is the identity function f(x) = x. You… Read More »Function Composition – 2629

Apply Transform Over Each Element in Array - 2635

Apply Transform Over Each Element in Array – 2635

🔗LC2635 🟢 Easy 🧩 Pattern – Array Transformations 📅 Day 5/30 Days of JavaScript Given an integer array arr and a mapping function fn, return a new array with a transformation applied to each element. The returned array should be created such that returnedArray[i] = fn(arr[i], i). Please solve it without the built-in Array.map method.… Read More »Apply Transform Over Each Element in Array – 2635

Counter II - 2665

Counter II – 2665

🔗LC2665 🟢 Easy 🧩 Pattern – Closures 📅 Day 4/30 Days of JavaScript Write a function createCounter. It should accept an initial integer init. It should return an object with three functions. The three functions are: Example Solution We return an object with the three required functions as properties, we implement a… Read More »Counter II – 2665