← Back to Arrays
Question 101
Add Items to the Cart
Add Items to the Cart
The push method adds a new element to the end of an array and changes the array in place. You start with a shopping cart holding two items. Push "bread" and then "butter" onto the cart. Afterwards, print the cart's length on one line, then print the whole cart on the next line.
Expected Output:
4 milk,eggs,bread,butter
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Arrays
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (clog, fn, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.