Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Jonathan C
Jonathan C
2,487 Points

Incorrect value shown after using pop() in the video "Remove Elements From an Array" by Guil Hernandez.

Hi! I would like to bring awareness to a possible mistake in the video to hopefully obtain an exterminator badge.

In the following statement shown in the video around 30-40 seconds:

let lastItem = shoppingList.pop();

lastItem should hold the value "coffee", not "honey". Since, pop() removed "coffee". The next example of shift() is correct.

2 Answers

Steven Parker
Steven Parker
230,917 Points

You forgot to identify the course, but assuming it's JavaScript Arrays, then at time index 00:38 in the Remove Elements From an Array lesson the 4-element array example changes to a new one showing a 3-element array. The last item in the array is "honey".

I'm not sure why they changed the example, and I also find it a bit confusing, but given the new example code the result of "honey" is indeed correct.

Also, instead of posting to the forum, the procedure for making content suggestions (and also for qualifying for the exterminator badge) is to submit your comments directly to the staff as described on the Support page. You could still let them know about the confusion if you want.

Jonathan C
Jonathan C
2,487 Points

Thank you for your response. In that case, in the new example with "honey", the video should have visually removed "honey" from the array in a similar manner to the "coffee" and "bread" examples. It can cause confusion. I think this was an oversight and thus bug to report. I'll send an email to support.

Steven Parker
Steven Parker
230,917 Points

It's definitely awkward to have the example change the first time by removing the last item, and then change it the second time by putting it back in.   :see_no_evil: