Playground for ES6 Maps
by cdeutsch
JavaScript
var data = new Map(Object.entries({
"100": {
make: "Buick",
model: "LeSabre"
},
"200": {
make: "Dodge",
model: "Neon"
},
"300": {
make: "Dodge",
model: "Stealth"
}
}));
//console.log(data, data.entries());
var result = [...data].reduce(function (accum, [key, car], index) {
console.log(key, car);
if (car.make === 'Dodge') {
accum.set(key, car);
}
return accum;
}, new Map());
console.log('RESULT', result, JSON.stringify([...result]))