1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| const products = [ {name: '반팔티', price: 15000}, {name: '긴팔티', price: 20000}, {name: '핸드폰케이스', price: 15000}, {name: '후드티', price: 30000}, {name: '바지', price: 25000} ];
const go = (...args) => reduce((a, f) => f(a), args); const add = (a, b) => a + b;
console.log( reduce( add, map(p => p.price, filter(p => p.price < 20000, products))));
go( products, products => filter(p => p.price < 20000, products), products => map(p => p.price, products), prices => reduce(add, prices), console.log);
go( products, filter(p => p.price < 20000), map(p => p.price), reduce(add), console.log);
|