Sleep in JavaScript

Sleep in JavaScript Given a positive integer millis, write an asyncronous function that sleeps for millis milliseconds. It can resolve any value. Example 1: Input: millis = 100 …

Read more

Curry in JavaScript

Curry in JavaScript Given a function fn, return a curried version of that function. A curried function is a function that accepts fewer or an equal number of parameters as the …

Read more

Memoize in JavaScript

Memoize in 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 …

Read more

Allow One Function Call

Allow One Function Call Given a function fn, return a new function that is identical to the original function except that it ensures fn is called at …

Read more

 Function Composition in JavaScript

 Function Composition in 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), …

Read more

Array Reduce Transformation

Array Reduce Transformation Given an integer array nums, a reducer function fn, and an initial value init, return a reduced array. A reduced array is created by applying the following …

Read more

Filter Elements from Array

Filter Elements from Array Given an integer array arr and a filtering function fn, return a new array with a fewer or equal number of elements. The returned array …

Read more

Counter II in 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 1: …

Read more

Counter in JavaScript

Counter in JavaScript Given an integer n, return a counter function. This counter function initially returns n and then returns 1 more than the previous value every subsequent time it is …

Read more

Skip to content