I have js object like this
var continents = [
0: {
short: 'na',
countries: [
{
name: 'canada'
},
{
name: 'usa'
},
//...
]
},
1: {
short: 'sa',
countries: [
{
name: 'chile'
},
{
name: 'colombia'
}
]
},
//...
]
I want to filter this object for matches with country name (contents.countries.name) with some string (example 'col') Example filter function
filter(item => {
return item.name.toLowerCase().indexOf('col'.toLowerCase()) >= 0;
});
Expecting result:
1: {
short: 'sa',
countries: [
{
name: 'colombia'
}
]
}