I have an array of objects. I want to loop over the array of objects and add a new item to each object in the array as seen below. This works as desired. However, es-lint is displeased and throws the following: "Assignment to property of function parameter 'dataRow'" Here is the description. My question is this. Is there a better way to do this. I am aware I can disable the rule. However, that is not best practice, which is what I am looking for here.
data.forEach((dataRow) => {
if (dataRow.title === 'Some title') {
dataRow.isDisplayed = displayValue;
}
if (dataRow.title === 'Some other title') {
dataRow.isDisplayed = displayValue;
}
});