const product = {
name: "Laptop",
price: 1299,
stock: 42,
discount: 0,
category: "Electronics",
};
const filtered = Object.entries(product)
.filter(([key, value]) => Boolean(value))
.reduce((acc, [key, value]) => {
acc[key] = value;
return acc;
}, {});
console.log(Object.keys(filtered).length);
console.log(Object.values(filtered).includes(0));
console.log(Object.keys(filtered).join(", ")); Post #3053
2.93K
CHALLENGE
- 👍 5
- 🔥 2