The syntax is therefore the following: parseFloat(string).
Where string represents the string to convert.
This function, as well as the previous parseInt determines if the first character of the string is a number and continues until it finds a different character.
Let’s see some practical examples in this regard.
Here are some examples with various text strings.
parseFloat("13.50"); parseFloat("13,56") parseFloat("13:50"); parseFloat("13-01-20"); parseFloat("13 01 20"); parseFloat("13years");
Instead, if we try to pass a string without any initial numeric character, the function returns NaN, as in the following cases:
Only the first parseFloat will give 13.5, all the others will give us the number 13.