You have to modify file index.js and create the methods for Shop Cart:
add(item, count)
– method should add the item to the cart;remove(item)
– method should remove the item from the cart;clear()
– method should clear the cart (remove all items);setCount(item, count)
– method should change quantity foritem
. If the method receivecount
below or equal zero, then it should throw Exception;
Important! You should change only index.js file.
To check your work we created a file with Jest tests. You can run tests with npm command: npm run test
.
Your work will be successful if all tests are green.