I am trying to construct an object for return. To avoid duplication of logic, some of the elements hinge on others. When I attempt to use 'this.' to reference already created items, it does not resolve.
function calcNextYear(lastYear) {
return {
age : lastYear.age + 1,
earnings : calcEarnings(lastYear.earnings,this.age),
savings : calcSavings(lastYear.endingAmount),
investmentIncome : calcInvestmentIncome(lastYear.endingAmount,this.age),
spending : calcSpending(this.age),
net : this.savings + this.investmentIncome - this.spending,
endingAmount : start.savingsAmount + this.net
}
}
The items not rendering are net and ending amount. 'start' is an existing object.