Hey. It seems elementary, but how to add two array elements containing "number". When folded, they are stuck together, not folded, for example, 3 + 2 = 32

    1 answer 1

    The question is not entirely clear. Only strings are added. Perhaps it was necessary to simply “bring” them to the number ( +'3' === 3 ).

     var arr = ['1','2',3,'4',5], sum = arr.reduce(function (prevSum, summand) { return +prevSum + +summand; }); console.log(sum); 

    reduce