Format Numeric Values

JavaScriptPosted on

This snippet put spaces between “number groups” to make the number more readable.

// 12244556215 -> 12 244 556 215
function format(value)
{
    return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
}

Need a web developer? Maybe we can help, get in touch!

Looking for web dev job?
You can check them on Jooble.

To see and write comments, you must allow the related (Disqus) cookies. For more information, please visit our privacy policy page.

Similar Posts

More content in JavaScript category