Skip to content

Commit 53734ef

Browse files
committed
[LES-4.8/st-compl] locales-intl-obj
Working with "Intl obj, NumberFormat() constructor". Worth noting: - this "Internationalization API". FS-dev: B-4 / JS advanced
1 parent 996f07b commit 53734ef

File tree

1 file changed

+31
-0
lines changed
  • full-stack-dev/4-js-advanced/4-calc-and-math/4-8-locales-intl-obj

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use strict';
2+
3+
const options1 = {
4+
style: 'currency',
5+
currency: 'RUB',
6+
// useGrouping: false,
7+
};
8+
9+
const options2 = {
10+
style: 'currency',
11+
currency: 'USD',
12+
};
13+
14+
const options3 = {
15+
style: 'decimal',
16+
};
17+
18+
const options4 = {
19+
style: 'percent',
20+
};
21+
22+
const options5 = {
23+
style: 'unit',
24+
unit: 'celsius',
25+
};
26+
27+
console.log(new Intl.NumberFormat('ru-RU', options1).format(23000)); // "23 000,00 ₽"
28+
console.log(new Intl.NumberFormat('en-US', options2).format(23000)); // "$23,000.00"
29+
console.log(new Intl.NumberFormat('ru-RU', options3).format(10000)); // "10 000"
30+
console.log(new Intl.NumberFormat('ru-RU', options4).format(0.1)); // "10 %"
31+
console.log(new Intl.NumberFormat('ru-RU', options5).format(25)); // "25 °C"

0 commit comments

Comments
 (0)