Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Multiplier Factory

A Closer Look at Functionsmedium

Course · Section 10: A Closer Look at Functions · Lecture 144: Closures

Implement `applyMultiplier(factor, nums)` that creates a multiplier function bound to `factor` via a closure and maps it over `nums`.

Sample tests

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

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Reading factor from outside instead of capturing it in the returned function.

Learning resources

  • MDN: Closures
Approach & explanation (try first)

The inner multiplier captures factor by closure, so mapping applies the same bound factor to each number.

Loading...
⌘/Ctrl + Enter

Run your code to see results.