Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculating currency [duplicate]

im trying to calculate currency but when i try it calculates only first number (1.25$+1.25$ returns 2$) this is the code that i made <-- done

var table = document.getElementById("table"), sumVal = 0;

for (var i = 1; i < table.rows.length; i++)
{
    sumVal = sumVal + parseInt(table.rows[i].cells[3].innerHTML);
}

document.getElementById("val").innerHTML =  +sumVal  + "€";
console.log(sumVal);

what should i add or edit so i can calculate entire value of that row and return 2 dollars and 50 cents

like image 892
Ibrahim S. Gerbiqi Avatar asked Jun 13 '26 20:06

Ibrahim S. Gerbiqi


1 Answers

replace parseInt with parseFloat

like image 87
apoteet Avatar answered Jun 16 '26 09:06

apoteet