replace object from array javascript 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));