Skip to content

Instantly share code, notes, and snippets.

@vladanyes
Created January 29, 2019 07:02
Show Gist options
  • Save vladanyes/7b8e538e479c1bebd21d5d63332df856 to your computer and use it in GitHub Desktop.
Save vladanyes/7b8e538e479c1bebd21d5d63332df856 to your computer and use it in GitHub Desktop.
Format float numbers.
function formatNumber(num) {
return Number(num).toFixed(2).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1 ').replace('.', ',').replace('.00', '');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment