As title explains im trying to understand the best way to refactor my function and also remove my if statement from the loop? Any guidance would be appreciated. As I have an idea that me else condition is useless.
function quantitySum(array) {
let sum = 0;
for (let i = 0; i < array[0].length; i++) {
if (array[0].length > 0) {
sum += parseFloat(array[0][i].f0_);
} else {
sum === 0;
}
}
return sum;
}
sum === 0doesn't do anything. It's a comparison, not an assignment, but you're not doing anything with the comparison result.