Skip to content

Instantly share code, notes, and snippets.

@neodigm
Created April 6, 2021 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neodigm/5eb3971895ca6acd66f13aa51cae5514 to your computer and use it in GitHub Desktop.
Save neodigm/5eb3971895ca6acd66f13aa51cae5514 to your computer and use it in GitHub Desktop.
export const kFormat = (num) =>
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