parse Float
Turn text that has just number characters into a floating point number value.
parseFloat("0.5");
You can change a text string having number characters into an actual floating point value. The text needs to have only number characters. This can also include the '-' and the '.'
symbols though.
If the text has other characters, like "-5.8g5u7", only -5.8 is returned since it is the best
attempt at converting to a number. So, try not to mix number characters with letters or other symbols.
Returns
- a floating point number value for the text number in the string.
Example
Take the first few digits of PI from the sentence and turn it into a number.
let text = "pi is 3.14...";
let pi = parseFloat(text.substr(6, 3));