parseInt-1

 

parseInt function will convert string to Integer value with specified radix. See code snippet below:

 
 
 
<!DOCTYPE html> <html> <head> <title>Welcome to LearnKode - A code learning platform</title> </head> <body> <button onclick="convertToInt()">Parse string to integer</button> <p id="sample"></p> <script> function convertToInt() { var a = parseInt("10") + "<br>"; var b = parseInt("10.00") + "<br>"; var c = parseInt("10.33") + "<br>"; var d = parseInt("34 45 66") + "<br>"; var e = parseInt(" 60 ") + "<br>"; var f = parseInt("40 years") + "<br>"; var g = parseInt("He was 40") + "<br>"; var h = parseInt("10", 10)+ "<br>"; var i = parseInt("010")+ "<br>"; var j = parseInt("10", 8)+ "<br>"; var k = parseInt("0x10")+ "<br>"; var l = parseInt("10", 16)+ "<br>"; var result = a + b + c + d + e + f + g + "<br>" + h + i + j + k +l; document.getElementById("sample").innerHTML = result; } </script> </body> </html>
Output