Here is a code snippet of a component I have written:
export class AppComponent {
public num1: number = 2;
public num2: number = 3;
public sum: number = 0;
public add() {
this.sum = this.num1 + this.num2;
}
}
However, when I run this code, instead of getting the correct sum of 5, I get 23. Can someone please provide me with a proper solution to fix this issue and achieve the correct addition result? Your help will be greatly appreciated!