This community-built FAQ covers the “The .pop() Method” exercise from the lesson “Arrays”.
Paths and Courses
This exercise can be found in the following Codecademy content:
FAQs on the exercise The .pop() Method
There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
Agree with a comment or answer? Like () to up-vote the contribution!
Need broader help or resources? Head here.
Looking for motivation to keep learning? Join our wider discussions.
Learn more about how to use this guide.
Found a bug? Report it!
Have a question about your account or billing? Reach out to our customer support team!
None of the above? Find out where to ask other questions here!
4 posts were split to a new topic: Still don’t get it how
2 posts were split to a new topic: What does it mean to mutate?
The problem with this exercise is that it does not explicitly specify that chores.pop(); deletes the item, while const removed = chores.pop(); stores it. I had the same problem and I had to experiment for some time with the code to figure it out.
just a little notice, the link for the MDN array documentation is broken, it can’t be “clicked”. you can copy the url and paste it in a new window tho.
P.S. The link in the project: “Secret Message” at the end of the array module is broken in the same way.
2 posts were split to a new topic: Does pop() need parameters?
2 posts were split to a new topic: They didn’t call .pop on the array
I’m kind of confused or maybe its a bug, i don’t know, the .pop() method is supposed to remove the last item of an array, but in this example, the item before the last one was removed (i.e ‘cook dinner’), I console log it to see the item removed, it was the second to the last word ‘cook dinner’ and calling the array again, it removed the last two item [‘cook dinner’, ‘mop floor’]. i’m confuse here.
here is the code:
const chores = [‘wash dishes’, ‘do laundry’, ‘take out trash’, ‘cook dinner’, ‘mop floor’];
.pop() twice? So two items are removes, but the first time you are not logging the removed item
so that means, this code; console.log(chores.pop()) is not logging the removed item but also removing another item and logging it to the console. Thank you, I understand better now.