I'm using jQuery, and I want to sum up the values in my table column, everything seems to work fine, but my value is returned a string with all the values added like: 123.5013.0012.35
How can I sum these properly?
var totals
$(".add").each(function(i) {
totals += parseFloat($(this).text()).toFixed(2);
});
console.log(totals);
toFixedbefore you've got the total? That turns it into a string, and then they're being appended. Your output should have clued you into that. Secondly, assuming it did work as you thought (stays as a float), you'd be lopping off precision before you got your total.