update element of object array es6 code example
Example: javascript find object in array and replace it
const updatedData = originalData.map(x => (x.id === id ? { ...x, updatedField: 1 } : x));
const updatedData = originalData.map(x => (x.id === id ? { ...x, updatedField: 1 } : x));