find object in array and update or create javascript code example
Example 1: javascript find object in array and replace it
const updatedData = originalData.map(x => (x.id === id ? { ...x, updatedField: 1 } : x));
Example 2: js array modify element
people[0] = "Georgie";