开发者

Addition turns into concatenation

开发者 https://www.devze.com 2023-03-18 03:37 出处:网络
var Height=(rowData.length * 30) + PPPP.top + 10 ; When 开发者_开发问答i print this i get 9013510... instead of 90 +135+10 = 235. Why does mine turns into concatentaion instead of Addition. You prob
var Height=  (rowData.length * 30) + PPPP.top + 10 ;

When 开发者_开发问答i print this i get 9013510... instead of 90 +135+10 = 235. Why does mine turns into concatentaion instead of Addition.


You probably need to convert PPPP.top to a number, eg.

var Height = (rowData.length * 30) + parseFloat(PPPP.top) + 10;


PPPP.top is probably a string. Try:

var Height=  (rowData.length * 30) + parseInt(PPPP.top, 10) + 10 ;


It's probably treating one of the values incorrectly as a string. Try using parseInt and see if that works:

var Height=  (rowData.length * 30) + parseInt(PPPP.top, 10) + 10;


You can use parseInt for that.

var Height=  (rowData.length * 30) + parseInt(PPPP.top, 10) + 10 ;

I have changed radix to base 10.

0

精彩评论

暂无评论...
验证码 换一张
取 消