I have a function like this:
flag: boolean = false;
some_function(){
var foo = some_num_value;
var bar = foo; // Trying to save value in a separate variable
if(this.flag){
var total = bar + foo;
}
return total;
!this.flag;
}
This above function runs 2 or 3 times in a single instance. The value of var foo changes for every iteration. I wish to save the value of each var foo such that I need to add it with the new value of var foo when the next iteration happens.
How can I go about this?