jquery - JavaScript - Receiving NAN when trying to divide a variable -


please checkout code:

var basicprice = newprice.substring(0, newprice.indexof('лв.')); var halfprice = (number.basicprice)/2; alert(halfprice); 

i receive output nan, when alert(basicprice); receive output 83.25 correct number why can not divide ?

where mistake, how can fix it?

thanks in advance!

you can preceed expression plus sign (+) convert numeric type

var basicprice = +newprice.substring(0, newprice.indexof('лв.')); var halfprice = basicprice/2; alert(halfprice); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -