I'm using this snippet to calculate the sum of two table cells.

var sum = 0;
    sum += parseFloat($(this).text());


But when the sum is for example 40.00 it displays as 40 and as picky as I am, i want it to display as 40.00. So... what to do?

Little (editable) demo: https://codepen.io/gentlemedia/pen/gGXJgR

I've found the answer myself :)

There is toFixed() method, so I had to add this to the sumvariable with the 2 as for the 2 decimals;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.