0

I have this code in javascript [ <strong>${item.party_election_result_obtained_vote} </strong> ]. How can i change this to a number format

<strong>${item.party_election_result_obtained_vote} </strong>

i want the code to be in number format, as it stands now, it reads something like 1000, i want it to read 1,000

devpro
  • 16,184
  • 3
  • 27
  • 38
  • A popular answer implies the use of regex [How to print a number with commas as thousands separators in JavaScript](https://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript) – Len Joseph Feb 06 '19 at 15:39

1 Answers1

1

You can use Intl.NumberFormat()

In example :

// us format
console.log(new Intl.NumberFormat('en-US').format(1000.42));

// french format
console.log(new Intl.NumberFormat('fr-FR').format(1000.42));
Cid
  • 14,968
  • 4
  • 30
  • 45