string to number conversion in javascript
<p>I have a function having following lines:</p>

<pre><code>payementReceived=data.toJSON().total;
paymentTotal=$("#paymentTotal").html();

console.log(typeof(parseInt(paymentTotal)));                  
console.log(typeof(parseInt(paymentReceived)));
console.log(parseInt(paymentTotal)-parseInt(paymentReceived));
</code></pre>

<p>I get the following in console</p>

<pre><code>number
number
NaN
</code></pre>

<p>i don't understand if both are numbers then why it isn't able to give the proper substraction result.</p>
