parseFloat-2

 
In this example, We will sum two floating point number and show that in paragraph tag. See the code snippet:
 
 
 
<!DOCTYPE html> <html lang="en-US"> <head> <title>Welcome to LearnKode - A code learning platform</title> </head> <body> <button onclick="convertToFloat()">Parse the string to float</button> <p id="sample"></p> <script> function convertToFloat() { var a = parseFloat("10"); var b = parseFloat("10.00"); var result = a + b; document.getElementById("sample").innerHTML = result; } </script> </body> </html>
Output