/ Published in: JavaScript
Rounds a number to a given decimal quantity
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function roundNumber(numero, dec) { var num=parseFloat(numero); var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec); return result; }