I am using javascripts .find()
function to return an object if a value exists however I get an undefined error
this.reduceoptionRadio = 'instalment'
this.calculatorResult =
[
{
"newCalculatedInstallmentsNo": "50",
"newContractEndDate": "20250701",
"newResidual": "0",
"newInstalment": "4071.91",
"newTerm": "52",
"outBalanceAvaf": null,
"restructureType": "term"
},
{
"newCalculatedInstallmentsNo": "52",
"newContractEndDate": "20250901",
"newResidual": "0",
"newInstalment": "3939.93",
"newTerm": "54",
"outBalanceAvaf": null,
"restructureType": "instalment"
}
]
this.calculateFormData = this.calculatorResult.find(
function(el) {
return el.restructureType === this.reduceoptionRadio;
}
);
console.log(this.calculateFormData);
How can I get the value of this.reduceoptionRadio
to reflect with the find function? The value of this.reduceoptionRadio
is dynamic, I just hardcoded here so I can have relevant code to explain.
Exact error in console reads ERROR TypeError: Cannot read property 'reduceoptionRadio' of undefined