const sum = (…args) => {
return args.reduce((a, b) => a + b, 0);
}
console.log(sum(1, 2, 3));
const sum = (…args) => {
return args.reduce((a, b) => a + b, 0);
}
console.log(sum(1, 2, 3));
Reduce takes 2 inputs. The function and the current value.
So 0 is the first current value.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.