Comments

3 comments

  • Rainer Grabowski

    Hi Martin,

    you can format it this way: YourNumber.toFixed(2).replace(/(\d)(?=(\d{3})+.)/g, '$1,')

    Rainer

    0
    Comment actions Permalink
  • admin

    Hi Rainer,

    I try your above advice but got this result:

    Code:

    var numRealMoney = @Sum of Money spent; //numRealMoney=11000000
    numRealMoney == null ? numRealMoney = 0 : numRealMoney=numRealMoney 

    numRealMoney.toFixed(2).replace(/(\d)(?=(\d{3})+.)/g, '$1,')  

    Result:

    1,1,0,0,0,000.00

     

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hi Admin, try his one: 

    numRealMoney.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ",")

    You can shorten your code this way: 

    @Sum of Money spent.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ",")

    Rainer

    1
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk