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
Post a Comment