Arrays of Objects: For each element in array 1, does an object value exist as a value in any of the objects in array 2
- by DevOtts
I have two arrays which contain objects in each element of the array.
var array1 = [{firstName: "John", lastName: "McDonald"}, {firstName: "Sandy", lastName: "Johnson"},....,]
var array2 = [{userName: "Donald"}, {userName: "John"},....,]
In psuedo-code, I want to do the following:
for each element in array1, is array1[i].firstName == to any of the userName's in array2. In plain english I want to look at each firstname in array1 and see if it exists at all in array2 as the value associated with the userName property.