Skip to content

LeetCode

Sleep - 2621

Sleep – 2621

🔗LC2621 🟢 Easy 🧩 Pattern – Promises and Time 📅 Day 13/30 Days of JavaScript Given a positive integer millis, write an asynchronous function that sleeps for millis milliseconds. It can resolve any value. Example Solution The promise will wait until the setTimeout completes and calls the resolve method, and the setTimeout… Read More »Sleep – 2621

Add Two Promises - 2723

Add Two Promises – 2723

🔗LC2723 🟢 Easy 🧩 Pattern – Promises and Time 📅 Day 12/30 Days of JavaScript Given two promises promise1 and promise2, return a new promise. promise1 and promise2 will both resolve with a number. The returned promise should resolve with the sum of the two numbers. Example Solution

Memoize – 2623

🔗LC2623 🟡 Medium 🧩 Pattern – Function Transformations 📅 Day 11/30 Days of JavaScript Given a function fn, return a memoized version of that function. A memoized function is a function that will never be called twice with the same inputs. Instead, it will return a cached value. You can assume there are 3 possible input functions: sum, fib, and factorial.… Read More »Memoize – 2623

Allow One Function Call - 2666

Allow One Function Call – 2666

🔗LC2666 🟢 Easy 🧩 Pattern – Function Transformations 📅 Day 10/30 Days of JavaScript Given a function fn, return a new function that is identical to the original function except that it ensures fn is called at most once. Example Solution

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