Format javascript value

Asked

Viewed 37 times

0

Hello friends I’m having trouble putting the values in real with javascript below this the code where this the price value preco = parseFloat (preco.replace(",",".") );the amount is R $ 60.90 with point, in this other format parseFloat (preco.replace(",","") ); he is like this R $ 6090 no point and no comma, I would like it to be like this: R $ 60,90 some beast there give this strength here

  • After the first preco that you put: preco = String(preco).replace('.', ',');

  • So I put String(price). replace('.', ','); got 060.50

  • 1

    To make calculations you have to use with dot. After doing the calculations you change to comma to display.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.