6
I have a string and I need to convert it to number, in case I need to convert it to a real value, but I’m not getting it. Below is an example where I try to convert the contents of a string into number so they can check.
const valor = parseFloat("109,99").toFixed(2)
console.log(valor, typeof valor)
In addition to not converting the value into a number, the code also returns me the wrong value because it was to return 109.99
instead of 109.00
.
Don’t forget to declare the variables. ;)
– Luiz Felipe
Python Mania kkk But put
var
or not in the global scope makes no difference right ?– JeanExtreme002
I have now seen the edition in the commentary. : ) In thesis,
var
today is falling into disuse.let
andconst
are preferable. See more about this here.– Luiz Felipe