DEV Community

Andrew Jackson
Andrew Jackson

Posted on

1 1

counters != countersWorking; SOLVED

Hey everyone as for the title I am having trouble with my counters not working. They are itemCounts and discountCounts. They are arrays that hold the value of ITEM_NAMES.length and DISCOUNT_NAME.length. This is a school practice project and those are the values I was given but I am not sure on how to use them to count the number of time the item or discount has been selected. Usually I would just use........... BARRROOOOOO!!!

I literally just figured out what my problem was. I just realized I am using arrays and because I am also using an if statement to check if it is the correct item I could just used that array point like so:

itemCounts[0]++;

I guess I was overthinking it the whole time because I was scared of failing and looking stupid.

Well thanks for your help?

The project is a gist here;

Top comments (0)

AWS Q Developer image

Your AI Code Assistant

Generate and update README files, create data-flow diagrams, and keep your project fully documented. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay