-
Notifications
You must be signed in to change notification settings - Fork 522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add commas to number #469
base: master
Are you sure you want to change the base?
Add commas to number #469
Conversation
@@ -0,0 +1,5 @@ | |||
~~~ javascript | |||
const addCommas = (num) => (!num) ? null : num.toString().split('.').map((n,i) => (i === 0) ? n.replace(/\B(?=(\d{3})+(?!\d))/g, ',') : n).join('.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove the check !num
? All of snippets assume that users pass valid parameters. So it looks like
const addCommas = (num) => [...`${num}`].map(...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it good now?
Can you resolve the conflicts? I will remove |
Still there is conflicts in this pull request ! |
Adds a comma after every three digits to the left of the decimal point.