Skip to content

Instantly share code, notes, and snippets.

@dheysonalves
Created November 26, 2020 15:43
Show Gist options
  • Save dheysonalves/831cd1a7283b31a9d9ca12fdaf5f7344 to your computer and use it in GitHub Desktop.
Save dheysonalves/831cd1a7283b31a9d9ca12fdaf5f7344 to your computer and use it in GitHub Desktop.
Format number to K letter
function kFormatter(num) {
return Math.abs(num) > 999 ? Math.sign(num)*((Math.abs(num)/1000).toFixed(1)) + 'k' : Math.sign(num)*Math.abs(num)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment