I want to update a property in each element in my array to be a particular index. However when I try the following:
static reindexComponentsOnMultiplePages(components) {
return components.forEach((el, idx) => (el.componentIndex = idx));
}
I get returned undefined.
My current array is as follows:
components = [
[ {...}, {...}, {...} ],
[ {...}, {...}, {...} ]
]
I was expecting each property in each element in my array to be updated. I call the method as follows:
pageComponents = MyService.reindexComponentsOnMultiplePages(pageComponents);
forEachisundefined. What did you expect to get?.map()?