Skip to content

Instantly share code, notes, and snippets.

@Renik07
Last active November 6, 2022 20:19
Show Gist options
  • Save Renik07/59d1c1927f7c3417d496f508b7ccd938 to your computer and use it in GitHub Desktop.
Save Renik07/59d1c1927f7c3417d496f508b7ccd938 to your computer and use it in GitHub Desktop.
Add spaces between numbers
const price = (value: number) => value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' ') + ' $';
// 99 450 $
price(99450);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment