Filter an array!
One of the most common actions is filtering an array to get some of the values
of the array. Luckily javascript has a nice method for this. The filter()
method.
With the following array of car brands we want to filter out the German brand.
const carBrands = [
{
brand: 'BMW',
origin: 'Germany'
},
{
brand: 'Fiat',
origin: 'Italy'
},
{
brand: 'Mercedes Benz',
origin: 'Germany'
},
{
brand: 'Ford',
origin: 'USA'
}
]
A snippet from a post templateTo