Answers for "how to add comas to thousands in js"

4

format money javascript commas

function formatMoney(n) {
    return "$ " + (Math.round(n * 100) / 100).toLocaleString();
}

n = 2123000;
// =>2,123,000
Posted by: Guest on November-09-2020
5

javascript format numbers with commas

function numberWithCommas(x) {
    return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
Posted by: Guest on July-29-2020

Code answers related to "how to add comas to thousands in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language