Baffled by issue with getDate() + x

Can anyone explain what is happening here?

I have a form which takes a date variable from a date picker, then generates 2 new dates, adding and subtracting a number of days, based on a number from an input box.

For some reason I cannot explain, the first getDate() line works perfectly (line 116 below), but the second (117) seems to add on 3 months!


This makes no sense to me - if I change line 117 to be an integer, it works perfectly:


Can anyone explain what is happening here? Am I doing something stupid?

OK, I realised that the issue was the way: sDate2.getDate() + PlusMinus was concatenating the values instead of adding them. Changing to: sDate2.getDate() + parseInt(PlusMinus) solved it.