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