1 function thousands(num) { 2 var result = [] 3 while (Math.floor(num / 1000)) { 4 var temp = num % 1000 5 result.push(temp) 6 num = Math.floor(num / 1000) 7 } 8 result.push(num) 9 return result.reverse().join(‘,‘) 10 } 11 console.log(thousands(11235784))
原文:https://www.cnblogs.com/codejoker/p/10371449.html