const prettify = (num, separator = ',') => {
const n = num.toString();
return n.replace(/(\d{1,3}(?=(?:\d\d\d)+(?!\d)))/g, "$1" + separator);
}
prettify(12346789); //12,346,789
prettify(12346789, '.'); //12.346.789
prettify(12346789, ' '); //12 346 789