만능 reduce? No!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>02/1</title>
<script src="../fx.js"></script>
</head>
<body>
<script>
const users = [
{ name: 'AA', age: 35 },
{ name: 'BB', age: 26 },
{ name: 'CC', age: 28 },
{ name: 'CC', age: 34 },
{ name: 'EE', age: 23 }
];
console.log(
_.reduce((total, u) => total + u.age, 0, users));
시작값이 없는 reduce가 더 간단한 연산을 한다.
console.log(_.reduce((a, b) => a + b, [1, 2, 3]));
console.log(
_.reduce((a,b) => a + b, L.map(u => u.age, users)));
const add = (a, b) => a + b;