Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Add commas to number #469

wants to merge 6 commits into from

Conversation

edlinkiii
Copy link

Adds a comma after every three digits to the left of the decimal point.

@@ -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('.');
Copy link
Owner

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(...)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it good now?

@phuocng
Copy link
Owner

phuocng commented Aug 27, 2021

Can you resolve the conflicts? I will remove package-lock.json.

@elkarouani
Copy link
Contributor

Still there is conflicts in this pull request !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants