Ad
Code
Diff
  • const addArr = function (arr) {
        if (arr.length == 0) {
            return null;
        } else {
            return arr.reduce((acc,i) => acc + i);
        }
    };
    
    • const addArr = (arr) => {
    • let sum = 0;
    • for (let i = 0; i < arr.length; i++) {
    • sum += arr[i];
    • }
    • return sum || null;
    • const addArr = function (arr) {
    • if (arr.length == 0) {
    • return null;
    • } else {
    • return arr.reduce((acc,i) => acc + i);
    • }
    • };
Code
Diff
  • const reverseStr = function(str) {
       return str.split('').reverse().join('');
    };
    • const reverse = str => [...str].reverse().join('');
    • const reverseStr = function(str) {
    • return str.split('').reverse().join('');
    • };