JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.5.0/lodash.js"></script>
JavaScript
var yourArray = [
{
arrivalTime: "10:30 PM",
availableSeats: 23,
boardingPoints: [{
id: "3882",
location: "abc",
time: "02:30PM"
},{
id: "3882",
location: "xyz",
time: "02:30PM"
}],
busType: "Scania Metrolink",
commPCT: 8,
departureTime: "1:15 PM",
droppingPoints: null,
},
{
arrivalTime: "10:30 PM",
availableSeats: 23,
boardingPoints: [{
id: "3882",
location: "def",
time: "02:30PM"
},{
id: "3882",
location: "jkl",
time: "02:30PM"
}],
busType: "Scania ",
commPCT: 8,
departureTime: "1:15 PM",
droppingPoints: null
}
];
var result = _.filter(yourArray, function(item) {
return _.size(_.intersection(['xyz', 'def'], _.map(item.boardingPoints, 'location')));
});
console.log(result);