Learn Basic OOP by Building a Shopping Cart - Step 19

Tell us what’s happening:

I believe my destructuring syntax is correct, but I"m not able to pass. It matches the object syntax, skips over the first property, and references the right array. Please advise!

Your code so far

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

/* file: styles.css */

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

  addItem(id, products) {
    const product = products.find((item) => item.id === id);
    const {, name, price, } = product;
  }

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36

Challenge Information:

Learn Basic OOP by Building a Shopping Cart - Step 19

Hi @maddeebee

You have a syntax error.

SyntaxError: unknown: Unexpected token (116:11)
114 | addItem(id, products) {
115 | const product = products.find((item) => item.id === id); >
116 | const {, name, price, } = product; | ^
117 | }
118 |

Happy coding

Thank you, I was misunderstanding the section of this article that discusses array/object destructuring. My code now passes! Thanks again.

1 Like