Every line of 'add comma to number javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
152 intComma: function intComma(number) { 153 var decimals = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1]; 154 155 return Humanize.formatNumber(number, decimals); 156 },
Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code
90 function addCommas(number) { 91 number += ''; 92 x = number.split('.'); 93 x1 = x[0]; 94 x2 = x.length > 1 ? ',' + x[1] : ''; 95 var rgx = /(\d+)(\d{3})/; 96 while (rgx.test(x1)) { 97 x1 = x1.replace(rgx, '$1' + '.' + '$2'); 98 } 99 return "R$ " + x1 + x2; 100 }