The parseFloat()
function takes a string as input, converts it to float, and returns the result.
parseFloat(string)
The only parameter for this function is a string
.
The function returns a floating-point number that is parsed from the string
.
NaN
is returned if the first non-whitespace character cannot be turned to float.console.log( parseFloat("56.019") )console.log( parseFloat(" 56.019 abc") )console.log( parseFloat("57") )console.log( parseFloat("68.9 55") )console.log( parseFloat("abc 56.019") )