0

I have a requirement where I should allow 0 after number and decimal number

Is there a way that I can let the user to show the number in $1.0 in this way and decimal number like $1.5 in $1.50 using JavaScript.

I tried this but it did not help me

addZero: function (q)
    {
        alert(q);
        //var a = ("0" + q).slice(-2);
        return q;
    }

But I don't know how to add 0 after number and after decimal number using JavaScript.

Bhavesh Odedra
  • 10,990
  • 12
  • 33
  • 58
Ajay Singh
  • 150
  • 2
  • 14
  • You are looking for `.toFixed(1)`, which will set the number to the "tens" place. `5..toFixed(1)` will result in "5.0" – TheIronDeveloper Jan 24 '15 at 07:47
  • But if i want to show $1.5 in $1.50 way...using .toFixed method i can only able to add 0 to whole number but for decimal number i cant get $1.50 – Ajay Singh Jan 24 '15 at 07:55

0 Answers0