Table of Contents
While HTML handles the design, it helps us to make our webpage intelligent. We can put a lot of checks, calculations, and strings in a smart way. We can also save the traffic to our server and do the calculations locally.
Many times this situation comes while programming any webpage when we need to convert a string to a number. The other day when I was writing another post “How to convert feet into centimeters” .
I was trying to design a calculator and forgot this particular function and had to search a lot before I could make it. So thought about writing a small post regarding the same. So let’s start.
The function is parseInt(string,radix)
We’ll take two examples. One without parsing and one after parsing the string into an integer.
1. IF E DON’T USE THE FUNCTION
We have a text field and a button.
We’ll put some numbers in the text field and press the button. We should get the output as that number +4.
2. USING THE PARSING FUNCTION