index.js
function addIntegerSeparators(x, separator) {
  x += '';
  if (!separator) return x;
  var rgx = /(\d+)(\d{3})/;
  while (rgx.test(x)) {
    x = x.replace(rgx, '$1' + separator + '$2');
  }
  return x;
}
function addIntegerSeparators(x, separator) {
  x += '';
  if (!separator) return x;
  var rgx = /(\d+)(\d{3})/;
  while (rgx.test(x)) {
    x = x.replace(rgx, '$1' + separator + '$2');
  }
  return x;
}
function addIntegerSeparators ( x , separator ) { x += '' ; if ( ! separator ) return x ; var rgx = / (\d+)(\d{3}) / ; while ( rgx . test ( x ) ) { x = x . replace ( rgx , '$1' + separator + '$2' ) ; } return x ; }
where x is already the integer part of the number
where x is already the integer part of the number