const addArr = (arr) => { const updateSum = (total, value) => total + value; const sum = arr.reduce(updateSum, 0); return sum ? sum : null; };
- const addArr = (arr) => {
let sum = 0;for (let i = 0; i < arr.length; i++) {sum += arr[i];}return sum || null;- const updateSum = (total, value) => total + value;
- const sum = arr.reduce(updateSum, 0);
- return sum ? sum : null;
- };