Build a Shopping Cart - Step 34

hi. totally blind, using jaws 2026. now up to step 34 of the project, and have to then do the for each for the buttons for the project, but wondering if fcc is having a timing issue and have done a reset of the lesson, done hard refreshes, rewritten the code and it is not passing. so can any one help me out? nd how to get this to pass. what is the code i need to get it to pass. is it my code, my logic or a fcc timing or bug. thanks.

marvin.

ps: pasting the java script code, the error and the link to the step.

java script:

 // Step 1–5: Grab DOM elements
const cartContainer = document.getElementById("cart-container");
const productsContainer = document.getElementById("products-container");
const dessertCards = document.getElementById("dessert-card-container");
const cartBtn = document.getElementById("cart-btn");
const clearCartBtn = document.getElementById("clear-cart-btn");
const totalNumberOfItems = document.getElementById("total-items");
const cartSubTotal = document.getElementById("subtotal");
const cartTaxes = document.getElementById("taxes");
const cartTotal = document.getElementById("total");
const showHideCartSpan = document.getElementById("show-hide-cart");
let isCartShowing = false;

// Step 6–12: Products array
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: 6, name: "Strawberry Ice Cream", price: 2.99, category: "Ice Cream" },
  { id: 7, name: "Chocolate Macarons (4 Pack)", price: 9.99, category: "Macaron" },
  { id: 8, name: "Strawberry Pretzel", price: 4.99, category: "Pretzel" },
  { id: 9, name: "Butter Pecan Ice Cream", price: 2.99, category: "Ice Cream" },
  { id: 10, name: "Rocky Road Ice Cream", price: 2.99, category: "Ice Cream" },
  { id: 11, name: "Vanilla Macarons (5 Pack)", price: 11.99, category: "Macaron" },
  { id: 12, name: "Lemon Cupcakes (4 Pack)", price: 12.99, category: "Cupcake" }
];

// Step 13–30: Render products
products.forEach(({ name, id, price, category }) => {
  dessertCards.innerHTML += `
    <div class="dessert-card">
      <h2>${name}</h2>
      <p class="dessert-price">$${price}</p>
      <p class="product-category">Category: ${category}</p>
      <button id="${id}" class="btn add-to-cart-btn">Add to cart</button>
    </div>
  `;
});

// Step 31: ShoppingCart class
class ShoppingCart {
  constructor() {
    this.items = [];
    this.total = 0;
    this.taxRate = 8.25;
  }

  addItem(id, products) {
    const product = products.find(p => p.id === id);
    this.items.push(product);

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

    const currentCount = totalCountPerProduct[product.id];
    const countSpan = document.getElementById(`product-count-for-id${id}`);

    if (currentCount > 1) {
      countSpan.textContent = `${currentCount}x`;
    } else {
      productsContainer.innerHTML += `
        <div id="dessert${id}" class="product">
          <p>
            <span class="product-count" id="product-count-for-id${id}"></span>${product.name}
          </p>
          <p>${product.price}</p>
        </div>
      `;
    }
  }
}

// Step 32: Instantiate cart
const cart = new ShoppingCart();

// Step 33–34: Use window.onload to make sure DOM is ready
window.onload = function() {
  const addToCartBtns = document.getElementsByClassName("add-to-cart-btn");
  const addToCartBtnsArray = [...addToCartBtns];

  // Step 34: forEach on the array (empty callback for now)
  addToCartBtnsArray.forEach((btn) => {
    // callback intentionally empty for Step 34
  });
};

error:
You should use the forEach method on the array you created.
link to the step:

As you have been asked before, please format your code when posting on the forum

You have a lot of content that is not part of the code given when you open this step. It is important to use the code given in the editor on the website as the starting point for each and every step.

I know I have said this before and I don’t understand why you insist upon ignoring everyone who tells you this.

If you don’t start with the code given for each step, you can get very confusing errors or not be able to pass the Step.

hi, well the forum is not the easiest site to navigate with a screen reader. so tried either control e and then since the forum was modified told to use control m, if theres another keyboard short cut to then preformat. try using it with a screen reader, close your eyes and use the keyboard. marvin.

You need to insert the backtick character three times on a line before your first line of code and three times on a line after your last line of code. However you do that is up to you

You did not follow the instructions

Do not pass a callback function yet.

hi, if you are not going to help me out, then pass my issue to some one else like ray who can help me out. and did paste from vs code, ad it is more accessible, then trying to use the editor. once i have my code correct with logic, then i then copy and paste to fcc. so use a screen reader your self and judge and put your self in my shoes, totally blind developer. thank you.
marvin.

I told you exactly what the problem is.

You absolutely need to start with the code you were given instead of pasting in code from VSCode. If you make changes other than what is requested, such as deleting all of the given code and pasting in code from another step from VSCode, then you will get confusing error messages.

It’s fine if you want to use VSCode, but you absolutely need to start with the code you are given for the step and not your old code from a previous step. If you want to use VSCode, I would copy the code you are given to start with for the step into VSCode, then made your changes, then copy back to the fCC editor. But you should not start with whatever code you have from the previous step.

Also, for this specific step, you need to fix the issue I pointed out.

You did not do what this line in the instructions said.

I am not sure why you don’t believe the half dozen or so of us who have said that you need to start with the code you are given for the step, but it is actually, really important.

You can use VSCode all you like, but you really must start with the initial code given for the Step instead of whatever old code you have from the last step. Copy the code you are given into VSCode instead of using your old code from the last step.

You will save yourself from so many confusing errors if you listen to the half dozen of us who have recommended this to you.

hi, okay went and rewrote the code and tried to understand. it is not passing still. so doing this from the fcc editor not vs code. so, is fcc timing out, or a bug. will paste the javascript code below. so what code do i need to get it to pass? thanks you.
marvin.
ps: pasting below.

javas script:

// Step 1–5: Grab DOM elements
const cartContainer = document.getElementById("cart-container");
const productsContainer = document.getElementById("products-container");
const dessertCards = document.getElementById("dessert-card-container");
const cartBtn = document.getElementById("cart-btn");
const clearCartBtn = document.getElementById("clear-cart-btn");
const totalNumberOfItems = document.getElementById("total-items");
const cartSubTotal = document.getElementById("subtotal");
const cartTaxes = document.getElementById("taxes");
const cartTotal = document.getElementById("total");
const showHideCartSpan = document.getElementById("show-hide-cart");
let isCartShowing = false;

// Step 6–12: Products array
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: 6, name: "Strawberry Ice Cream", price: 2.99, category: "Ice Cream" },
  { id: 7, name: "Chocolate Macarons (4 Pack)", price: 9.99, category: "Macaron" },
  { id: 8, name: "Strawberry Pretzel", price: 4.99, category: "Pretzel" },
  { id: 9, name: "Butter Pecan Ice Cream", price: 2.99, category: "Ice Cream" },
  { id: 10, name: "Rocky Road Ice Cream", price: 2.99, category: "Ice Cream" },
  { id: 11, name: "Vanilla Macarons (5 Pack)", price: 11.99, category: "Macaron" },
  { id: 12, name: "Lemon Cupcakes (4 Pack)", price: 12.99, category: "Cupcake" }
];

// Step 13–30: Render products
products.forEach(({ name, id, price, category }) => {
  dessertCards.innerHTML += `
    <div class="dessert-card">
      <h2>${name}</h2>
      <p class="dessert-price">$${price}</p>
      <p class="product-category">Category: ${category}</p>
      <button id="${id}" class="btn add-to-cart-btn">Add to cart</button>
    </div>
  `;
});

// Step 31: ShoppingCart class
class ShoppingCart {
  constructor() {
    this.items = [];
    this.total = 0;
    this.taxRate = 8.25;
  }

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

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

    const count = totalCountPerProduct[id];
    const countSpan = document.getElementById(`product-count-for-id${id}`);

    if (count > 1) {
      countSpan.textContent = `${count}x`;
    } else {
      productsContainer.innerHTML += `
        <div id="dessert${id}" class="product">
          <p>
            <span class="product-count" id="product-count-for-id${id}"></span>${product.name}
          </p>
          <p>${product.price}</p>
        </div>
      `;
    }
  }
}

// Step 32: Instantiate ShoppingCart
const cart = new ShoppingCart();

// Step 33–34: Grab all "Add to Cart" buttons and use forEach
const addToCartBtns = document.getElementsByClassName("add-to-cart-btn");
const addToCartBtnsArray = [...addToCartBtns];
addToCartBtnsArray.forEach(() => {}); // Step 34: empty callback for now

error:
You should use the forEach method on the array you created.

You need to start with the starting code was originally in the fCC editor for this step, not your old code you’ve been using from VSCode. If you do not have that code, you should reset the code for this step.

Once you have that code, you can edit that exact code in either VSCode or the fCC editor. But you need to use the starting code the Step gives you.

This line is wrong - you are not following the instruction: “Do not pass a callback function yet.”

hi, okay so the fcc was having issues. so i then went nuclear. closed the tab, then cleared cache for 24 hours, signed out, signed back in, and then went to step 34, it is still not passing, is it my code, my logic, timing for fcc or a bug. an is your version for step 34 passing? if so, then show me how to then get this step to pass. whats the code i should use. please dont castigate me or be rude, be professional, kind, and not cold. you come across cold in your replies. you have never had to deal with a blind student learning to code and using a screen reader. so if you cannot be more empthatic, then i would like some one else like ray, he has been kind, and curteous and generous. so, can you help me out. if not, then get some one else to help me. have tried to learn and it is not passing and the fcc was not set up for blind user using a screen reader so have tried and tried and want to learn,not to do it for me, but struggling through this stupid system and the checker is very sctrict . pity it could be a bit more liberal. but that would be too much work having to rewrite the editor and the system. understand that, just frustrated. am i the only blind person doing this course. do you know of any other blind people? if so, can you ask them to contact me so i could get in touch and then once made contact to then compare notes and experiences with screen readers. thank you.
marvin.
ps: pasting my code from the fcc and the error.
help!
totally frustrated. have researched it online to understand what it is doing, looked at similar code. and still it is failing. is it me, or not understanding, being stupid, dumb because i cannot see. have done multiple resets and refresh and written the code a few times.

ps::: pasting below.

java script:

const cartContainer = document.getElementById("cart-container");
const productsContainer = document.getElementById("products-container");
const dessertCards = document.getElementById("dessert-card-container");
const cartBtn = document.getElementById("cart-btn");
const clearCartBtn = document.getElementById("clear-cart-btn");
const totalNumberOfItems = document.getElementById("total-items");
const cartSubTotal = document.getElementById("subtotal");
const cartTaxes = document.getElementById("taxes");
const cartTotal = document.getElementById("total");
const showHideCartSpan = document.getElementById("show-hide-cart");
let isCartShowing = false;

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: 6,
    name: "Strawberry Ice Cream",
    price: 2.99,
    category: "Ice Cream",
  },
  {
    id: 7,
    name: "Chocolate Macarons (4 Pack)",
    price: 9.99,
    category: "Macaron",
  },
  {
    id: 8,
    name: "Strawberry Pretzel",
    price: 4.99,
    category: "Pretzel",
  },
  {
    id: 9,
    name: "Butter Pecan Ice Cream",
    price: 2.99,
    category: "Ice Cream",
  },
  {
    id: 10,
    name: "Rocky Road Ice Cream",
    price: 2.99,
    category: "Ice Cream",
  },
  {
    id: 11,
    name: "Vanilla Macarons (5 Pack)",
    price: 11.99,
    category: "Macaron",
  },
  {
    id: 12,
    name: "Lemon Cupcakes (4 Pack)",
    price: 12.99,
    category: "Cupcake",
  },
];

products.forEach(
  ({ name, id, price, category }) => {
    dessertCards.innerHTML += `
      <div class="dessert-card">
        <h2>${name}</h2>
        <p class="dessert-price">$${price}</p>
        <p class="product-category">Category: ${category}</p>
        <button 
          id="${id}" 
          class="btn add-to-cart-btn">Add to cart
        </button>
      </div>
    `;
  }
);

class ShoppingCart {
  constructor() {
    this.items = [];
    this.total = 0;
    this.taxRate = 8.25;
  }

  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(`product-count-for-id${id}`);

    currentProductCount > 1 
      ? currentProductCountSpan.textContent = `${currentProductCount}x`
      : productsContainer.innerHTML += `
      <div id="dessert${id}" class="product">
        <p>
          <span class="product-count" id="product-count-for-id${id}"></span>${name}
        </p>
        <p>${price}</p>
      </div>
      `;
  }
};

const cart = new ShoppingCart();
const addToCartBtns = document.getElementsByClassName("add-to-cart-btn");
const addToCartBtnsArray = [...addToCartBtns]; // convert HTMLCollection to array

// Step 34: call forEach (no callback yet)
addToCartBtnsArray.forEach(btn => {
  btn.addEventListener("click", () => {
    cart.addItem(parseInt(btn.id), products);
  });
});

error:
You should use the forEach method on the array you created.

. .

try to not create addToCartBtnsArray , but do the spread and forEach all on one line

hi, it is still not passing, a screen reader user. also some times when i have stray characters or hidden characters. jaws, nvda and windows narrator does not read those hdiden characters. so have to guess and then try to delete. so can you show me the exact code how to get step 34 to pass. have done multiple resets, multiple refreshes, written the code several times, but not passing, think fcc may have a timing issue or maybe some thing else. so just frustrated. as i live in adelaide, it will be 14 or 15 hours tomorrow if help from you to get this to pass. step 28 it took me 36 hours before it passed. so, fcc could be improve for accessibility for screen reader users. should have built the system with accessibility from the ground up, not just as an afterthought. rant over. so can you help me? trying my best, first time doing this sort of project. and yes, did listen to the lectures, read the transcripts, did the example code. so did all that. so pasting my javascript below and the error message. so totally frustrated. so any help?
i know i am the only blind person and you are thinking to your self oh no not this person again! thanks marvin.
ps: pasting below.

javascript:

// Step 1–33: DOM elements
const cartContainer = document.getElementById("cart-container");
const productsContainer = document.getElementById("products-container");
const dessertCards = document.getElementById("dessert-card-container");
const cartBtn = document.getElementById("cart-btn");
const clearCartBtn = document.getElementById("clear-cart-btn");
const totalNumberOfItems = document.getElementById("total-items");
const cartSubTotal = document.getElementById("subtotal");
const cartTaxes = document.getElementById("taxes");
const cartTotal = document.getElementById("total");
const showHideCartSpan = document.getElementById("show-hide-cart");
let isCartShowing = false;

// Step 2–12: Products array
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: 6, name: "Strawberry Ice Cream", price: 2.99, category: "Ice Cream" },
  { id: 7, name: "Chocolate Macarons (4 Pack)", price: 9.99, category: "Macaron" },
  { id: 8, name: "Strawberry Pretzel", price: 4.99, category: "Pretzel" },
  { id: 9, name: "Butter Pecan Ice Cream", price: 2.99, category: "Ice Cream" },
  { id: 10, name: "Rocky Road Ice Cream", price: 2.99, category: "Ice Cream" },
  { id: 11, name: "Vanilla Macarons (5 Pack)", price: 11.99, category: "Macaron" },
  { id: 12, name: "Lemon Cupcakes (4 Pack)", price: 12.99, category: "Cupcake" }
];

// Step 13–24: Generate dessert cards
products.forEach(({ name, id, price, category }) => {
  dessertCards.innerHTML += `
    <div class="dessert-card">
      <h2>${name}</h2>
      <p class="dessert-price">$${price}</p>
      <p class="product-category">Category: ${category}</p>
      <button id="${id}" class="btn add-to-cart-btn">Add to cart</button>
    </div>
  `;
});

// Step 25–33: ShoppingCart class
class ShoppingCart {
  constructor() {
    this.items = [];
    this.total = 0;
    this.taxRate = 8.25;
  }

  addItem(id, products) {
    const product = products.find(item => item.id === id);
    if (!product) return;

    this.items.push(product);

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

    const productCount = countPerProduct[product.id];
    const productSpan = document.getElementById(`product-count-for-id${id}`);

    if (productCount > 1) {
      if (productSpan) productSpan.textContent = `${productCount}x`;
    } else {
      productsContainer.innerHTML += `
        <div id="dessert${id}" class="product">
          <p>
            <span class="product-count" id="product-count-for-id${id}"></span>${product.name}
          </p>
          <p>${product.price}</p>
        </div>
      `;
    }
  }
}

// Step 34: Initialize cart and attach event listeners
const cart = new ShoppingCart();

// Use spread operator and forEach in one line
[...document.getElementsByClassName("add-to-cart-btn")].forEach(btn =>
  btn.addEventListener("click", () => cart.addItem(parseInt(btn.id), products))
);

error:
You should use the spread operator on the addToCartBtns variable.

fCC tests are not having issues on this step. You are using the wrong starting code. You must use the starting code the step gives you. You need to stop using your code from the last step that you saved in VSCode instead of the starting code the step gives you.

Also, this line here, the one I keep quoting, has a callback function even though the instructions tell you not to use a callback function.

When we tell you something is incorrect, you need fix it or you will not be able to pass the Step. If you don’t fix the errors we point out, then the code will not pass.

I am trying to write clearly in the hopes that you will fix the problems that I am telling you are in your code.

Note: we cannot write the answer for you. That is not allowed. Please do not ask us to write the answer code for us. We cannot break the forum rules about writing answers for people.

I understand that you are frustrated, but I think that you could greatly reduce the amount of time you spend on each step if you do the following things.

  1. Always use the starting code from the fCC editor. Never use your old code from VSCode as the starting code.

  2. Read each sentence of the instructions carefully and do what it says. If you do not understand what a sentence is telling you to do, then ask us what that sentence means.

  3. When we tell you what is wrong in your code, try to fix it and then tell us what you did to try to fix the specific things we told you to fix. If you don’t understand something we say, then ask questions about it instead of ignoring it.

now you have removed addToCartBtns, please reset the step and do not delete that variable

hi, can you tell me what fcc is looking for. have reset the lesson, refreshed the page, rewritten the ocde, but step 34 is not passing and cannot see any hidden characters. hidden trailling spaces. so just frustrated. not passing and tried a few hours. so what am i doing wrong? i know you cannot give me the exact code, just out of sheer frustration, and have tried to get this to work, and now 18 hours of trying. so, what am i doing wrong. what is fcc lookign for and can you point me out how to get htis to pass, without exact code and where i can then fix this, will share my code and the error. just totally blind and also if stray characters, my screen readers does not see them in fcc, do have a backup copy in vs code, just in case the editor chrashes, get corrupted or gets stuck. so alway have a back up local copy so pasting my code below. sorry to be a pian, trying to learn, but fcc if very tricky and fiinacky. and driving me almost insane, have tried, and also did research online how this step works or the code and what it is doing, so have done all i can and want to learn. so how to get this to pass. or will it every pass, is it my stupid code or logic, not correct or fcc having a fit, got stuck, wrong timing in the dom, or what else, so just frustrated and tired. so just want to get this to pass. had a similar issue and took me 36 hours until step 28 would pass. it may be easy for you sighted people, but try putting your self in my shoes totally blind and srelying on a screen reader and fighting the fcc which was not built for blind developers from the ground up, obscure messages, and then trying to figure it out. so can you help. and please be gentle. dont be cold, i know i am only one blind developer and trying to do my best and to learn this stuff. rant over.
ps: so need your help today if possible, in australia.
ps:: pasting my java script below.

// Get references to DOM elements
const cartContainer = document.getElementById("cart-container");
const productsContainer = document.getElementById("products-container");
const dessertCards = document.getElementById("dessert-card-container");
const cartBtn = document.getElementById("cart-btn");
const clearCartBtn = document.getElementById("clear-cart-btn");
const totalNumberOfItems = document.getElementById("total-items");
const cartSubTotal = document.getElementById("subtotal");
const cartTaxes = document.getElementById("taxes");
const cartTotal = document.getElementById("total");
const showHideCartSpan = document.getElementById("show-hide-cart");
let isCartShowing = false;

// Products array
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: 6, name: "Strawberry Ice Cream", price: 2.99, category: "Ice Cream" },
  { id: 7, name: "Chocolate Macarons (4 Pack)", price: 9.99, category: "Macaron" },
  { id: 8, name: "Strawberry Pretzel", price: 4.99, category: "Pretzel" },
  { id: 9, name: "Butter Pecan Ice Cream", price: 2.99, category: "Ice Cream" },
  { id: 10, name: "Rocky Road Ice Cream", price: 2.99, category: "Ice Cream" },
  { id: 11, name: "Vanilla Macarons (5 Pack)", price: 11.99, category: "Macaron" },
  { id: 12, name: "Lemon Cupcakes (4 Pack)", price: 12.99, category: "Cupcake" }
];

// Render products into the dessert cards container
products.forEach(({ name, id, price, category }) => {
  dessertCards.innerHTML += `
    <div class="dessert-card">
      <h2>${name}</h2>
      <p class="dessert-price">$${price}</p>
      <p class="product-category">Category: ${category}</p>
      <button id="${id}" class="btn add-to-cart-btn">Add to cart</button>
    </div>
  `;
});

// ShoppingCart class
class ShoppingCart {
  constructor() {
    this.items = [];
    this.total = 0;
    this.taxRate = 8.25;
  }

  addItem(id, products) {
    const product = products.find(p => p.id === id);
    this.items.push(product);

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

    const currentCount = totalCountPerProduct[product.id];
    const productCountSpan = document.getElementById(`product-count-for-id${id}`);

    if (currentCount > 1) {
      productCountSpan.textContent = `${currentCount}x`;
    } else {
      productsContainer.innerHTML += `
        <div id="dessert${id}" class="product">
          <p>
            <span class="product-count" id="product-count-for-id${id}"></span>${product.name}
          </p>
          <p>${product.price}</p>
        </div>
      `;
    }
  }
}

// Instantiate cart
const cart = new ShoppingCart();

// Get the buttons and convert to array
const addToCartBtns = document.getElementsByClassName("add-to-cart-btn");
const addToCartBtnsArray = [...addToCartBtns];

// ✅ Step 34: This is exactly what the test expects
addToCartBtnsArray.forEach;

error:

Like we said above, you need to use the starting code fCC gives you for the step instead of your old code from VSCode. It is actually, seriously, really important.

Also, you need to call the forEach but pass no callback.

please do not create addToCartBtnsArray , use forEach directly on the array created with the spread operator