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 trialDouglas Watts
5,464 PointsArrays:Push & Pop
Trying to follow along with Push & Pop, This script:
//Push
var my_array = [2,3,4];
console.log(my_array.toString());
my_array.push(5);
console.log(my_array.toString());
//Pop
var value = my_array.pop;
console.log(my_array.toString());
is supposed to cut the '5' off of the end, but mine won't work.....any idea's?
4 Answers
Stone Preston
42,016 Pointsyou are missing the () on your pop method call
you have
var value = my_array.pop;
try
var value = my_array.pop();
Tristan Gaebler
6,204 PointsThis is my code for that section: ``` var my_array = [2, 3, 4]; console.log(my_array.toString());
my_array.push(5); console.log(my_array.toString());
var value = my_array.pop(); console.log(my_array.toString()); ```
Hope that helps.
Jason Anello
Courses Plus Student 94,610 PointsHi Douglas,
You have: var value = my_array.pop;
You're missing the parentheses on the end. You need them in order to call the method.
var value = my_array.pop();
Douglas Watts
5,464 PointsAh.....i see it!
I will try and keep a better eye,thanks.