FI - round function
by Luis Valle
JavaScript
(function () {
var x = '47,357';
var y = amountRound(x);
alert(y);
})();
function amountRound(num) {
num = (Math.round(parseFloat((num.replace(/\,/g, ''))) / 100) * 100);
while (/(\d+)(\d{3})/.test(num.toString())) {
num = num.toString().replace(/(\d+)(\d{3})/, '$1'+','+'$2');
}
return num;
}