asked on
function f(n) {
return (Math.round(n*100)/100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
ASKER
ASKER
ASKER
How do I debug my code ...whats wrong ?Your code have nothing wrong but the function from The_Big_Daddy you're using...
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",").toFixed(2);
}
by :function numberWithCommas(n) {
return (Math.round(n*100)/100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
ASKER
ASKER
JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.
TRUSTED BY
return x.toString().replace(/\B(?
}
alert( numberWithCommas( 1234567.458' ) );