Still working my way through functional programming: .forEach(), .map(), .filter(), .reduce().
I'm working through a new challenge.
var bikes = [
{name: 'Cinelli Bolt', price: '2000', age: 1, singlespeed: 'yes', features: ['tubeless tires', 'disk brakes', 'carbon frame']},
{name: 'Cinelli Mash', price: '1700', age: 3, singlespeed: 'yes', features: ['gatorskin tyres', 'sram drivetrain', 'steel frame']},
{name: 'Specialized Langster', price: '1000', age: 1, singlespeed: 'no', features: ['two speed enclosed hub', 'bullbars', 'carbon frame']}
];
I'm trying to filter the array by a specific feature 'carbon frame'. I was thinking about using filter but I'm confused about calling the feature inside the key.value pair.
var justCarbonBikes = bikes.filter(function(bike) {
return bike.features['carbon frame'];
});
Expected result should modify the original array:
var bikes = [
{name: 'Cinelli Bolt', price: '2000', age: 1, singlespeed: 'yes', features: ['tubeless tires', 'disk brakes', 'carbon frame']},
{name: 'Specialized Langster', price: '1000', age: 1, singlespeed: 'no', features: ['two speed enclosed hub', 'bullbars', 'carbon frame']}
];