I have a TypeScript class where there are no import statements at the top. The issue I am facing is that when I use calculateDate() and run the addMonth(new Date(), 1) function, it ends up adding 11 months to today instead of just 2. Upon investigation, I realized that the variable m is always resulting from string concatenation rather than a mathematical addition operation. I even attempted using parseInt() on the string form of both operands, but it still performs string concatenation. Can someone please provide guidance on how to fix this issue? Thank you.
export class calculateDate {
addMonth(thisDate:Date, monthCount:number){
if (thisDate && monthCount && monthCount != -1) {
let m : number = thisDate.getMonth() + monthCount;
console.log('m=', m);
let newDate: Date = new Date(thisDate.setMonth(m));
return newDate;
}
else
return null;
}
}