File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
full-stack-dev/4-js-advanced/4-calc-and-math/4-8-locales-intl-obj Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 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"
You can’t perform that action at this time.
0 commit comments