Lets say there are two javascript arrays. What I want to find out is how to take the second array and find out if there is another person that has the same favoriteColor as someone in the first array. If there is I want it to switch arrays. They keep the same position as the person they are switching with. Anyone know how that can be done.
var array1 = [
{
name: 'Person 1',
favoriteNumber: '1',
hairColor: 'Brown',
strongHand: 'Left'
},
{
name: 'Person 2',
favoriteNumber: '2',
hairColor: 'Brown',
strongHand: 'Left'
},
{
name: 'Person 3',
favoriteNumber: '3',
hairColor: 'Blonde',
strongHand: 'Right'
}
var array2 = [
{
name: 'Person 4',
favoriteNumber: '2',
hairColor: 'Blonde',
strongHand: 'Right'
},
{
name: 'Person 5',
favoriteNumber: '22',
hairColor: 'Blonde',
strongHand: 'Right'
}