Last active
September 20, 2026 09:18
-
-
Save cgsdev0/0b58bc1430cbdfb018293bb5e4142717 to your computer and use it in GitHub Desktop.
format number js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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