Learn Basic OOP by Building a Shopping Cart - Step 7

Tell us what’s happening:

This is the error message i get after adding the desserts from the table. Not sure what else to do or why I’m getting this error message.

TypeError: undefined is not an object (evaluating ‘products[1].id’)]
[

Your code so far

<!-- file: index.html -->

/* file: script.js */
// User Editable Region

const products = [
  {
    id: 1,
    name: "Vanilla Cupcakes (6 Pack)",
    price: 12.99,
    category: "Cupcake",
    id: 2,
    name:"French Macaron",
    price:	3.99,
    category:	"Macaron",

    id: 3,
    name:"Pumpkin Cupcake",
    price:	3.99,
  category:"Cupcake",

    id: 4,
  name:"Chocolate Cupcake",
  price: 5.99,
  category: "Cupcake",

    id: 5,
    name: "Chocolate Pretzels (4 Pack)",
    price: 10.99,
    category:	"Pretzel",

    id: 5,
    name: "Strawberry Ice Cream",
    price:	2.99,
    category:	"Ice Cream",

    id: 6,
    name: "Chocolate Macarons (4 Pack)", 
    price:	9.99, 
    category:	"Macaron",

    id: 7, 
    name: "Strawberry Pretzel",	
    price: 4.99,
    category: "Pretzel",

    id:8,
    name: "Butter Pecan Ice Cream", 
    price: 	2.99,	
    category: "Ice Cream",

    id: 9,
    name: "Rocky Road Ice Cream",	
    price: 2.99,	
    category: "Ice Cream",

    id:10,
    name: "Vanilla Macarons (5 Pack)",
    price: 11.99,
    category: "Macaron",

    id: 11,
    name: "Lemon Cupcakes (4 Pack)",
    price: 12.99,
    category:	"Cupcake"
},
];






// User Editable Region
/* file: styles.css */

Your browser information:

User Agent is: Mozilla/5.0 (iPad; CPU OS 18_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/133.0.6943.84 Mobile/15E148 Safari/604.1

Challenge Information:

Learn Basic OOP by Building a Shopping Cart - Step 7

TypeError: undefined is not an object (evaluating ‘products[1].id’)]
It’s having problems finding .id within the product.

Within your array [ ], there is one object { } with multiple ids/name/price/category. Each object should be wrapped in { }

1 Like

Go through and look closely at your information entered. Check the name, id, category, price and see that you have doubled up somewhere!

each product should be an object, it should not be everything in an object