let num = 1234567.89; let commas = num.toLocaleString("en-US"); commas = num.toString().replace(/B(?=(d{3})+(?!d))/g, ",");