Solution Review: Club Entry System
This lesson will explain the solution to the problem in the previous lesson.
Solution review #
Press + to interact
const filter = func => arr => arr.filter(func);const map = func => arr => arr.map(func);const funcCompose = (...funcs) => args => funcs.reduceRight((arg, fn) => fn(arg), args);function test(customers){const ans = funcCompose(map(x => x.name),filter(x => x.age >= 18))(customers)return ans}const customers = [ { name: "Hermoine", age: 15 },{ name: "Ron", age: 18 },{ name: "Harry", age: 24 },]console.log(test(customers))
Explanation #
You were given two functions, filter
and map
(lines 1 & 2).
-
filter
applies the function,func
, on each element of the array,arr
, on which it is called. -
map
...
Access this course and 1400+ top-rated courses and projects.