Ad
Code
Diff
  • function addArr(arr){
      if(arr.length == 0) return null
      return arr.reduce((acc, i) => acc + i, 0)
    }
    • function addArr(arr){
    • if(arr.length === 0) return null
    • let final = 0
    • arr.forEach(num => {
    • final += num
    • })
    • return final
    • if(arr.length == 0) return null
    • return arr.reduce((acc, i) => acc + i, 0)
    • }