To change the value of an object in an array: Call the findIndex () method to get the index of the specific object. The findIndex arr1.map (obj => arr2.find (o => o.id === obj.id) || obj); Here, arr2.find (o => o.id === obj.id) will return the element i.e. Here's how it works: Split the string into pieces by the search string : javascript . Determine if that length is the largest we have seen so far. Javascript finds an object in an array by property value and update Javascript update object property in array ES6