Número com vírgulas JS
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
kripi__
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
function numberWithCommas(x) {
return x.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",");
}
var number = 3500;
console.log(number.toLocaleString());
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//
};