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