Ad
Code
Diff
  • "use strict";
    
    function addArr(arr) {
      return arr.length === 0
        ? null
        : arr.reduce((acc, x) => acc + x, 0);
    }
    • function addArr(arr){
    • if(arr.length === 0) return null
    • let final = 0
    • arr.forEach(num => {
    • final += num
    • })
    • return final
    • "use strict";
    • function addArr(arr) {
    • return arr.length === 0
    • ? null
    • : arr.reduce((acc, x) => acc + x, 0);
    • }