Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Step Pipeline

A Closer Look at Functionsmedium

Course · Section 10: A Closer Look at Functions · Lecture 137: First-Class and Higher-Order Functions

Implement `pipeline(value, steps)` that applies a sequence of named steps to `value` in order. Steps are `inc` (add 1) or `double` (multiply by 2).

Sample tests

Input: pipeline(3, ["inc","double"])
Output: 8
Input: pipeline(5, [])
Output: 5

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Applying steps in the wrong order; reduce goes left to right.

Learning resources

  • MDN: Array iteration methods
Visualize this concept: Currying →
Approach & explanation (try first)

reduce threads the value through each named step in order, composing a small pipeline.

Loading...
⌘/Ctrl + Enter

Run your code to see results.