Learn Basic OOP by Building a Shopping Cart - Step 41

How do i add the getCounts method to the ShoppingCart class

Your code so far

ShoppingCart().getCounts(items)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Challenge Information:

Learn Basic OOP by Building a Shopping Cart - Step 41

I’m still stuck I need help please

“Add a getCounts method to the ShoppingCart class.”

You would do this the same way you added the addItem method to the ShoppingCart class.

“…return the number of items in the items array.”

In other words, the length of the items array.

3 Likes

This is what I’ve come up with so far please do anyone have any hints

items = new ShoppingCart().getCounts();

hi there!

you did not following the hints given above.