Learn Basic OOP by Building a Shopping Cart - Step 57

Tell us what’s happening:

Your if statement should set the items property back to an empty array.
dont know why not working

Your code so far

if(isCartCleared)
{
items.length = !this.items.length;
total= 0;
}
}

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 (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 57

“set the items property back to an empty array”

Look at the constructor for this class to remind yourself how to do this.

“then set the total property to 0

Same thing, look at the constructor.

When you first create a ShoppingCart object, its items array is empty and its total count is set to 0. This is done in the constructor. These instructions are asking you to do the same thing if the user decides to clear their cart.

3 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.