19.04.23 14:59 작성
·
213
1
const _reduce = (fns, acc, iter) => {
if(!iter){
iter = acc[Symbol.iterator]();
acc = iter.next().value;
}
for (const a of iter){
acc = fns(acc, a);
}
return acc
};
console.log(
_reduce(
(total_price, product) => total_price + product.price,
0,
products)
);