const inventory = {
apples: 5,
bananas: 12,
cherries: 0,
dates: 8,
};
const result = Object.entries(inventory)
.filter(([_, qty]) => qty > 0)
.reduce((acc, [fruit, qty]) => {
acc[fruit] = qty * 2;
return acc;
}, {});
const keys = Object.keys(result);
const values = Object.values(result);
console.log(keys.length, values.reduce((sum, v) => sum + v, 0)); Post #3060
2.79K
CHALLENGE
- 👍 7
- ❤ 2
- 🔥 2