Giacomo Balli profile picture
Giacomo Balli
Complex decisions. Clear thinking.

Independent advice for business owners navigating technology decisions, challenges and opportunities.
Fluent in business. Grounded in technology. Paid only by you.

Let’s Talk It Through LinkedIn

Building technology products since 2010 · 100+ apps

Format large number with commas

This code sample will allow you to format a large number with commas for easier user reading.

function numberWithCommas(x) {
    return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}

Directions:
- call numberWithCommas(x);

Note:
This snippet focuses on iOS development. Make sure to verify/adapt any vendor prefixes. Back to main listing.

Published: Sun, Jan 10 2016 @ 18:53:30
Back to Blog