Solution: Objects
Review possible solutions to the tasks for the objects challenge.
We'll cover the following...
We'll cover the following...
Solution 1
Here is a possible solution for adding and removing items from a list object.
Explanation
-
Lines 1–2: The
myListobject is created with an empty items array. -
Lines 3–5: The function
add()is used to add an item to the items array. When called, it pushes the provided item to the end of the array. -
Lines 7–12: The method
remove()...