var num;
var num_str;
var result = '';

// check args
if (process.argv.length < 3) { // sample value
  num = Math.floor(Math.random() * 1000000000) + 1;
} else {
  num = process.argv[2];
}
console.log('input: ' + num);

num_str = Number(num).toString();

while (num_str.length > 0) {
  var three_digits = num_str.slice(-3); // get 3 digits
  result = three_digits + result;

  num_str = num_str.slice(0, -3);	// remove 3 digits
  if (num_str.length >= 1) {
    result = ',' + result;
  }
}

console.log(result);

@@ -10,263 +10,429 @@
 var 
-num_str;%0Avar result = '';%0A%0A// check args%0Aif (process.argv.length %3C 3) %7B // sample value%0A  num = Math.floor(Math.random() * 1000000000) + 1;%0A%7D else %7B%0A  num = process.argv%5B2%5D;%0A%7D%0Aconsole.log('input: ' + num);%0A%0Anum_str = Number(num).toS
+result;%0A%0Avar getIntegerDecimalPart = function(num) %7B%0A   var integer = Math.floor(num);%0A   var decimal = (num - integer).toFixed(5); // temporarily, 5 digits to appear after the decimal point%0A   var str_decimal = ('0.00000' != decimal) ? decimal.slice(1) : '';%0A   return %7Binteger: integer.toString(), decimal: str_decimal%7D;%0A%7D;%0A%0Avar getCommaDelimitedIntegerPart = function(s
 tr
+_
 in
-g();%0A%0Awhile (num_st
+teger) %7B%0A  var out = '';%0A  while (str_intege
 r.le
@@ -439,24 +439,26 @@
 ngth %3E 0) %7B%0A
+  
   var three_
@@ -466,22 +466,26 @@
 igits = 
-num_st
+str_intege
 r.slice(
@@ -507,21 +507,20 @@
 igits%0A  
-resul
+  ou
 t = thre
@@ -534,35 +534,42 @@
 s + 
-resul
+ou
 t;%0A%0A  
-num_str = num_st
+  str_integer = str_intege
 r.sl
@@ -603,20 +603,26 @@
 its%0A
+  
   if (
-num_st
+str_intege
 r.le
@@ -642,36 +642,374 @@
     
-result = ',' + result;%0A  %7D%0A%7D
+  out = ',' + out;%0A    %7D%0A  %7D%0A  return out;%0A%7D%0A%0A// check args%0Aif (process.argv.length %3C 3) %7B // sample value%0A  num = Math.floor(Math.random() * 1000000000) + 1;%0A%7D else %7B%0A  num = process.argv%5B2%5D;%0A%7D%0Aconsole.log('input: ' + num);%0A%0Avar obj_num = getIntegerDecimalPart(Number(num));%0Aresult = obj_num.decimal;%0Aresult = getCommaDelimitedIntegerPart(obj_num.integer) + result;
 %0A%0Aco

Deal with decimal, currently 5 digits to appear after the decimal point