Platform
Resources
Pricing
Sign in
Get started
Javier Sánchez Mendoza
Move forward and Don't stop until you're proud 📈
Workspace
Fork
Public
SAT
By
Javier Sánchez Mendoza
Edited
Oct 24, 2023
Insert cell
Insert cell
function
quantityFormat
(
num
)
{
return
''
+
num
.
toFixed
(
2
)
.
replace
(
/(\d)(?=(\d{3})+(?!\d))/g
,
'$1,'
)
;
}
Insert cell
quantityFormat
(
17000000000
)
;
Insert cell
function
arrayQuantityFormat
(
array
)
{
function
quantityFormat
(
num
)
{
return
''
+
num
.
toFixed
(
2
)
.
replace
(
/(\d)(?=(\d{3})+(?!\d))/g
,
'$1,'
)
;
}
let
arrayNumbers
=
array
.
map
(
Number
)
;
let
result
=
arrayNumbers
.
map
(
quantityFormat
)
;
return
result
;
}
Insert cell
list
=
[
"17000000000"
,
"2"
,
"3"
]
Insert cell
arrayQuantityFormat
(
list
)
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
quantityFormat
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
arrayQuantityFormat
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
list
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML