Skip to content

Instantly share code, notes, and snippets.

View coolreader18's full-sized avatar

Noa coolreader18

View GitHub Profile
@coolreader18
coolreader18 / commas.js
Last active January 26, 2018 14:59
Properly separate a large number.
/**
* Separate a large number into commas
* @param {Number} num The number to split up
* @param {Object|String} opts Options, for now it's just joiner is the possible joiner, if you'd like to use dots instead of commas or something.
* @example
* commas(12345678) // returns 12,345,678
* @example
* commas(211409200504011, {joiner:"."}) // returns 211.409.200.504.011
*/
function commas(num, opts) {