Learn Basic OOP by Building a Shopping Cart - Step 26

Tell us what’s happening:

I think I am missing something small here. it keeps giving me this prompt: " ou should use a template literal to query the id value."

Thank you in advance for the help!

Your code so far

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

const totalCountPerProduct = {};
this.items.forEach((dessert) => {
  totalCountPerProduct[dessert.id] = (totalCountPerProduct[dessert.id] || 0) + 1;
})

const currentProductCount = totalCountPerProduct[product.id];
const currentProductCountSpan = document.getElementById('id');
id.innerHTML = `<p>product-count-for-id${product.id}<p>`

}
WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3.1 Safari/605.1.15

Challenge Information:

Learn Basic OOP by Building a Shopping Cart - Step 26

Welcome to the forum @2xhd6zm584

The id value of the document.getElementById needs to be

as mentioned in the instructions.

Remove the paragraph tags, as they are not needed.

Happy coding

The code is still not submitting. Here is my new line of code:
id.innerHTML = product-count-for-id${product.id}

You do not need id.innerHTML
Place the id directly into the .getElementById method.

Ah it worked that time. Thank you!

1 Like

i solved this in the first instance but the confusing part was in the question the "id value " this part need to be replaced with “Id value”