I'm having a bit of a problem that's probably going to have a stupidly simple solution which I'm missing.
I'm passing a formField
here to a function which I'm them using to update a parameter in an object in an array.
The problem I'm finding though is that I'm currently able to select the item in the array from the index, but then when I try and select the property (let's say op
in this example) using the variable I'm not able to get it
Just was wondering what I'm missing and if it's possible to pass a variable as the selector for the object's property?
async function updateFilter(id, formField, value){
const indexNum = filterArray.map(item => item.id).indexOf(id);
if (indexNum !== -1) {
filterArray[indexNum].formField = value;
}
console.log(filterArray);
}