Skip to content

Instantly share code, notes, and snippets.

@MSerj
Created April 13, 2018 07:41
Show Gist options
  • Save MSerj/ad23c73f65e3610bbad96a5ac06d4924 to your computer and use it in GitHub Desktop.
Save MSerj/ad23c73f65e3610bbad96a5ac06d4924 to your computer and use it in GitHub Desktop.
format number with spaces
function numberWithSpaces(nr) {
return nr.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
}
@oshliaer
Copy link

oshliaer commented Jun 23, 2023

new Intl.NumberFormat('ru-RU', { style: 'decimal' }).format(num);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment