Skip to content

Instantly share code, notes, and snippets.

@cgsdev0
Last active September 20, 2026 09:18
Show Gist options
  • Select an option

  • Save cgsdev0/0b58bc1430cbdfb018293bb5e4142717 to your computer and use it in GitHub Desktop.

Select an option

Save cgsdev0/0b58bc1430cbdfb018293bb5e4142717 to your computer and use it in GitHub Desktop.
format number js
function a(b, c = 0) {
d=b.length
if (!d) return ''
n = b[d - 1]
let r = ((n != '-' && c && !(c % 3)) ? ',' : '') + n + a(b.slice(0, d - 1), c + 1)
if (!c) return r.split('').reverse().join('')
return r
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment