Answers for "javascript space as thousand separator"

8

How to print a number with commas as thousands separators in JavaScript

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

how to separate thousands with comma in js

const totalBalance = (x, y) => {
    let total = parseInt(x.replace(/,/g, ""))  +  parseInt(y.replace(/,/g, ""));
    return total.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",");
    //Output structure will be like:23,236//
  };
Posted by: Guest on January-26-2022

Code answers related to "javascript space as thousand separator"

Code answers related to "Javascript"

Browse Popular Code Answers by Language