Convert Javascript number to two decimal places : <p>I know there have been many threads on this topic but none seem to answer my question directly. I want to convert a number to two decimal places no matter the length. So 0.5 should turn into 0.50, and 5.3145 should go to 5.31. Most importantly, I also need to keep the number as a number datatype. I know toFixed(2) will create two decimal places, but this also turns the number into a string. If I wrap the toFixed(2) with a parseInt function (e.g. parseInt(amount.toFixed(2))) then 0.5 seems to be converted to "0.50", and then back to 0.5 with out the trailing zero. Adding a second layer of parentheses doesn't solve the problem either. Any ideas?? Thank you in advance!</p>
