MediumPro challengeJavaScriptTypeScript

Point-Free Style

Functional ProgrammingPoint-FreeComposition

Point-free style defines functions without explicitly mentioning their arguments.
It relies on composition and partial application.

// pointful — argument x is mentioned explicitly
const double = x => x * 2;
const doubleAll = arr => arr.map(x => double(x));

// point-free — no explicit argument
const double = x => x * 2;
const doubleAll = arr => arr.map(double); // or: map(double)

Refactor the given pointful functions into point-free style using the provided helpers.
All functions should produce identical results.

Sample tests

Test #1doubleAll([1,2,3,4]) = [2,4,6,8]
Input: [[1,2,3,4],"doubleAll"]
Output: [2,4,6,8]
Test #2evens([1,2,3,4,5]) = [2,4]
Input: [[1,2,3,4,5],"evens"]
Output: [2,4]
Test #3total([1,2,3,4,5]) = 15
Input: [[1,2,3,4,5],"total"]
Output: 15