DEV Community

Tutsmake
Tutsmake

Posted on

JavaScript parseFloat: Convert String to Float Number

In this Javascript tutorial, we will discuss about the javaScript parseFloat () function, you will learn what is parseFloat in javascript and what it does. You will learn from this javascript parseFloat example. After finishing this quick guide, you will be familiar with JavaScript Parsing () syntax and where you should use it.

// return float value
a = parseFloat(" 10 ")
document.write('parseFloat(" 10 ") = ' +a +"<br>");

b = parseFloat("123abc")
document.write('parseFloat("123abc") = '+b +"<br>");

// returns NaN value
c = parseFloat("abc456")
document.write('parseFloat("abc456") = ' +c +"<br>");

d = parseFloat("3.14")
document.write('parseFloat("3.14") = '+d +"<br>");

// returns only first Number
e = parseFloat("18 2 2019")
document.write('parseFloat("18 2 2019") = ' +e +"<br>");

Continue Reading https://www.tutsmake.com/javascript-parsefloat-convert-string-into-float-no-javascript/

Top comments (1)

Collapse
 
mkubdev profile image
Maxime Kubik

It's only for traffic.. why don't you write your full article here to the the Dev.to community?