Add commas or spaces to group every three digits

前端 未结 9 1736
日久生厌
日久生厌 2020-11-27 15:50

I have a function to add commas to numbers:

function commafy( num ) {
  num.toString().replace( /\\B(?=(?:\\d{3})+)$/g, \",\" );
}

Unfortun

9条回答
  •  无人及你
    2020-11-27 16:23

    This worked for me:

    function commafy(inVal){
       var arrWhole = inVal.split(".");
       var arrTheNumber = arrWhole[0].split("").reverse();
       var newNum = Array();
       for(var i=0; i

提交回复
热议问题