When using array.some, I am having trouble getting a single array as an output.
I attempted the following code:
data = [{
Surname: 'Santos',
Firstname: 'Carlos'
},
{
Surname: 'Reyes',
Firstname: 'Carla'
},
{
Surname: 'Michael',
Firstname: 'Lebowski'
}
];
var found = data.some(function(data) {
return data.Surname === 'Reyes'
})
console.log(found);
The logs being returned are:
0: {Surname: 'Santos', Firstname: 'Carlos'}
1 : {Surname: 'Reyes', Firstname: 'Carla'}
2 : {Surname: 'Michael', Firstname: 'Lebowski'}
My expected logs were:
0: {Surname: 'Reyes', Firstname:'Carla'}
How can I modify my code to get the desired output?