Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Numbers</h1> <h2>The parseInt() Method</h2> <p>Number.parseInt() converts strings to whole numbers:</p> <p id="demo"></p> <script> document.getElementById("demo").innerHTML = Number.parseInt("-10") + "<br>" + Number.parseInt("-10.33") + "<br>" + Number.parseInt("10") + "<br>" + Number.parseInt("10.33") + "<br>" + Number.parseInt("10 6") + "<br>" + Number.parseInt("10 years") + "<br>" + Number.parseInt("years 10"); </script> </body> </html>