How to iterate the array and get the sum of them. i have add array of string that are decimals. For example :
function check() {
let arr = ["1,50", "1,50"];
let sum1 = 0;
let sum2 = "0";
let sum3 = 0
for (let i = 0, length = arr.length; i < length; i++) {
sum1 += +arr[i];
sum2 += +arr[i];
sum3 += arr[i];
}
console.log(sum1, sum2, sum3)
//sum1 = NaN
//sum2 = '0NaNNaN'
//sum3 = 01,501,50
}
Author - comments - 0