Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Function Returning a Function

A Closer Look at Functionsmedium

Course · Section 10: A Closer Look at Functions · Lecture 139: Functions Returning Functions

Implement `multiplyAll(factor, nums)` that builds a multiplier by calling a `makeMultiplier(factor)` function which returns a function, then maps it over `nums`.

Sample tests

Input: multiplyAll(3, [1,2,3])
Output: [3,6,9]
Input: multiplyAll(0, [5])
Output: [0]

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Returning the factory itself instead of calling it.
Approach & explanation (try first)

makeMultiplier returns a closure bound to factor, used directly as the map callback.

Loading...
⌘/Ctrl + Enter

Run your code to see results.