score:0

To loop that we first need to loop the first array then find element with title in the second array and add the JSON key we want to add as well

array1.map(elem => {
       const arr2WithTitle = arr2.find((data)=>data.name === elem.name);
         return arr2WithTitle.title ? data.title =arr2WithTitle.title: arr2WithTitle.title = "none"
     
    })

score:1

Your two arrays don't correspond to a useful output based on your requirements

Stating them a bit clearer

  1. If a value of the property name in array2 is not any of the values of the array elements of array1 then do not add the array2 element to the new array
  2. If the value of the property name in array2 is in array1 AND the array element doesn't have the property title, add this to the array element.

Based on that criteria, you will get an empty array based on your arrays array1 and array2.

const array1 = [
  { name: "Jack",      age: 54, title: "IT Engineer" },
  { name: "Josephine", age: 54, title: "chef"        },
  { name: "Cortez",    age: 34, title: "driver"      }
];

const array2 = [
  { name: "Alex",     age: 24,                      },
  { name: "Janvier",  age: 24, title: "IT Engineer" }
];

const array1_Values = array1.map(elem => elem.name);
const newArray = array2.filter(elem => {
  if (array1_Values.includes(elem.name) && !elem.hasOwnProperty('title')) {
    elem.title = 'none';
    return elem;
  } 
})

console.log(newArray); // Prints [] to console

Related Query

More Query from same tag