* add commas after every three numbers * @param {string|number} x * @return {string}
(x)
| 19330 | * @return {string} |
| 19331 | */ |
| 19332 | function addCommas(x) { |
| 19333 | if (isNaN(x)) { |
| 19334 | return '-'; |
| 19335 | } |
| 19336 | x = (x + '').split('.'); |
| 19337 | return x[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g, '$1,') |
| 19338 | + (x.length > 1 ? ('.' + x[1]) : ''); |
| 19339 | } |
| 19340 | |
| 19341 | /** |
| 19342 | * @param {string} str |
no outgoing calls
no test coverage detected