mirror of https://github.com/Lissy93/dashy.git
🔀 Merge pull request #468 from rubenandre/fix-putCommasInBigNum-utils
🐛 Fix putCommasInBigNum logic
This commit is contained in:
commit
56866d5a31
|
@ -75,7 +75,8 @@ export const getPlaceUrl = (placeName) => {
|
|||
/* Given a large number, will add commas to make more readable */
|
||||
export const putCommasInBigNum = (bigNum) => {
|
||||
const strNum = Number.isNaN(bigNum) ? bigNum : String(bigNum);
|
||||
return strNum.replace(/\B(?=(?:\d{3})+(?!\d))/g, ',');
|
||||
const [integerPart, decimalPart] = strNum.split('.');
|
||||
return integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',') + (decimalPart ? `.${decimalPart}` : '');
|
||||
};
|
||||
|
||||
/* Given a large number, will convert 1000 into k for readability */
|
||||
|
|
Loading…
Reference in New Issue