so I have and array assetCost = "350000.00","500000.00" so in a for loop Im trying to do this:
result += parseFloat(assetCost[rowIndex-1],10).toFixed(2);
but the problem is that instead of adding is concatenating.
thanks for your help.
The only way I can see that happening is if the result variable were a string.
As Jeff said, that happens because your values are primitives of type String, not Number. And that is due to the fact that the method toFixed() transforms again a Number into a String.
Anyway, toFixed() is used mainly to display the final result, so that you may apply it after you finish the calculation.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)