I have an array of objects that I need to iterate through. If a match is found, I want to slice that object.
var object = [
{
"Name": 'Kshitij',
"LastName": 'Rangari',
"CountryBorn": 'India',
"CountryStay": 'USA'
},
{
"Name": 'Pratik',
"LastName": 'Rangari',
"CountryBorn": 'India',
"CountryStay": 'Canada'
},
{
"Name": 'Pratibha',
"LastName": 'Rangari',
"CountryBorn": 'India',
"CountryStay": 'India'
},
{
"Name": 'Ankita',
"LastName": 'Raut',
"CountryBorn": 'India',
"CountryStay": 'Australia'
},
{
"Name": 'Wayne',
"LastName": 'Rooney',
"CountryBorn": 'UK',
"CountryStay": 'UK'
}
]
console.log(object);
object.forEach(function(x){
if (x.Name==='Kshitij'){
}
})
object.map(obj => {
obj.AllFirstName = obj['Name'];
console.log(obj['AllFirstName']);
})
console.log('------------------------------')
console.log(object);
I need to loop through the objects in the array and remove those with Name === 'Kshitij'
and Name ==='Pratik'
.
How should I go about achieving this?