Tell us what’s happening:
the variable product was referred to as “an array” in the previous step 18. In order to get the correct submission I had to deconstruct product using an obj {}. Was this an typo in step 18?
Can you deconstruct an object with an array and vice versa?
Also, the tutorials I’ve seen show you have to “skip” over items in order to reference the correct item in the array/object being deconstructed. Could you explain why we dont have to in this case?
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
addItem(id, products) {
const product = products.find((item) => item.id === id);
const [, name, product] = product; //What I thought was correct

const {name, product} = product; //what passed submission
}
// User Editable Region
/* file: styles.css */
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Challenge Information:
Learn Basic OOP by Building a Shopping Cart - Step 19