Confusion with arithmetic operators in Javascript
<p>While I do know that the following question is stupid simple, it is related to a specific situation that I have been unable to find through Google. The following code is in Javascript.</p>

<p>Suppose there is a variable </p>

<pre><code>x = x + 1;
</code></pre>

<p>I can see from a tutorial that this is supposed to work. However, how are we supposed to use this variable in a calculation?</p>

<p>I have tried with the following codes</p>

<pre><code>var name = name + 1;
alert(name);
</code></pre>

<p>The above outputs "NaN"; whatever that is...</p>

<pre><code>var name = name + 1;
name = 2;
alert(name);
</code></pre>

<p>The above outputs 2 which is simply overriding the original variable.</p>

<pre><code>name = prompt("input any number");
var name = name + 1
alert(name);
</code></pre>

<p>The above outputs the input provided + 1 as a <strong>string</strong>, i.e. 01 where the input is "0" without quotes.</p>

<p>I remember from a ruby lesson that we use .to_i in order to convert a string to an integer. How do we go about doing this in Javascript?</p>
