How to add zero to kopecks?

  • 0
    I have a price like this: 1 360,70 ₽ .
    I need to calculate this data, I do it like this:
    let cena = $(".price").text(); 
    cena = cena.replace(',', '.');
    cena = cena.replace(' ', '');
    cena = parseFloat(cena);

    After the necessary operations, I need to convert to the original form.
    cena = cena.toLocaleString();	
    $(".price").text(cena + ' ₽');

    But the view is obtained without zero (not .70 but .7 )
    How can this zero be added where needed?
    JavaScript Anonymous, Sep 2, 2019

  • 2 Answers
  • 0

  • 0
    Number (1360.7) .toFixed (2)
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!