this post was submitted on 05 Apr 2024
11 points (92.3% liked)

Web Development

3434 readers
2 users here now

Welcome to the web development community! This is a place to post, discuss, get help about, etc. anything related to web development

What is web development?

Web development is the process of creating websites or web applications

Rules/Guidelines

Related Communities

Wormhole

Some webdev blogsNot sure what to post in here? Want some web development related things to read?

Heres a couple blogs that have web development related content

CreditsIcon base by Delapouite under CC BY 3.0 with modifications to add a gradient

founded 1 year ago
MODERATORS
top 5 comments
sorted by: hot top controversial new old
[–] [email protected] 6 points 7 months ago (1 children)

Its worth creating an Intl formatter outside of a loop, then applying it inside the loop - if you are formatting everything in the loop the same.

const formatter = Intl.NumberFormat(/* options */);
return items.map(item => {
   return {
      ...item,
      total: formatter.format(item.total)
   }
});

...Or however you choose to mutate an array.

Well, certainly it used to be. Not sure if that is still the case!

[–] [email protected] 1 points 7 months ago
[–] [email protected] 3 points 7 months ago (1 children)

I live in Canada and I've never seen "1.000,00". Canada (at least the anglophone part that I live in) follows the usual "1,000.00" format. Why is this library using commas as decimal separators?

[–] [email protected] 1 points 7 months ago (1 children)

This is very interesting. I agree that some of the formatting puzzled me as well. I would assume this follows some standard even when the use of said standard is uncommon. I have for example not seen 1.000,00 € used, but I thought that perhaps if you live in Germany, France, or another EU country then it is common.

[–] [email protected] 2 points 7 months ago

Yup, that's indeed the format used in some European countries. Canada was surprising though. 🤷‍♂️