Ad
Code
Diff
  • const addArr = (arr) => {
      return arr.length === 0 ? null : arr.reduce((value, num) => {
        return value += num
      },0)
    };
    
    • const addArr = (arr) => {
    • let sum = 0;
    • for (let i = 0; i < arr.length; i++) {
    • sum += arr[i];
    • }
    • return sum || null;
    • return arr.length === 0 ? null : arr.reduce((value, num) => {
    • return value += num
    • },0)
    • };