Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
function number_with_delimiter(number, delimiter) {
number = number + '', delimiter = delimiter || ',';
var split = number.split('.');
split[0] = split[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1' + delimiter);
return split.join('.');
};
// Test drive
number_with_delimiter(12345678)
> 12,345,678
number_with_delimiter(12345678, ':')
> 12:345:678
number_with_delimiter(12345678.555)
> 12,345,678.555
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.