We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Intl.NumberFormat
1 parent 2683404 commit 30e2f1bCopy full SHA for 30e2f1b
app/helpers/format-num.js
@@ -1,22 +1,9 @@
1
import { helper } from '@ember/component/helper';
2
3
-export function formatNum(value) {
4
- if (value === 0) {
5
- return '0';
6
- }
+const numberFormat = new Intl.NumberFormat('en');
7
8
- let ret = '';
9
- let cnt = 0;
10
- while (value > 0) {
11
- if (cnt > 0 && cnt % 3 === 0) {
12
- ret = `,${ret}`;
13
- cnt = 0;
14
15
- ret = (value % 10) + ret;
16
- cnt += 1;
17
- value = Math.floor(value / 10);
18
19
- return ret;
+export function formatNum(value) {
+ return numberFormat.format(value);
20
}
21
22
export default helper(params => formatNum(params[0]));
0 commit comments