I have an array of objects. Each object has many fields, but I want to update the linePosition field in all of the objects. I simply want to decrement it by one. Would map be my best bet here?
dmikester11/13/2023
If it matters, this array is a React state array.
ScriptyChris1/13/2023
You can simple do a loop
ScriptyChris1/13/2023
for (const object of array) {
object.property_to_update = 'new value';
}
ScriptyChris1/13/2023
Oh, in this case use functional update with .map() to avoid state mutation