Hey there! I'm working on implementing a "your cart" feature for an ecommerce website in my project, and I could use some assistance with coding to loop through an object within an object. Below is the code snippet I've been working on:
var products = {
product1: {
name: "Balenciaga Black Shoes",
quantity: 2,
price: 50,
size: "L",
shipping: 20
},
product2: {
name: "Gucci Pink Bag",
quantity: 1,
price: 70,
size: "Big",
shipping: 20
}
};
function myFunc() {
for (const key in products) {
for (const key2 in key) {
console.log(`${key2}: ${key[key2]}`);
}
}
}
myFunc()