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 JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Review Adding and Removing Items from Arrays

I've been workin' on this for days now can someone help me? Can't seem to find the answer

https://teamtreehouse.com/library/javascript-arrays-and-loops/tracking-multiple-items-with-arrays/review-adding-and-removing-items-from-arrays

I don't know the answers to this quiz and i've been working for days so can someone help me out?

Maybe I'm Just a bit dumb xD

Thanks! Channon

1 Answer

Marco Amadio
Marco Amadio
4,882 Points

Hi Channon.

In this quiz you have to use some array methods:

The unshift method adds an element at the beginning of an array. e.g.

var array = [1, 2, 3];
array.unshift(0);

/* The results will be */

[0, 1, 2, 3]

The push method adds an element at the end of an array. e.g.

var array = [1, 2, 3];
array.push(4);

/* The results will be */

[1, 2, 3, 4]

The shift method removes the first element of an array. e.g.

var array = [0, 1, 2, 3];
array.shift();

/* The result will be */

[1, 2, 3]

The pop method removes the last element of an array. e.g.

var array = [1, 2, 3, 4];
array.pop();

/* The result will be */

[1, 2, 3]

The length porperty will return the number of elements in an array.

var array = [0, 1, 2, 3];
var length = array.length;

/* length variable's value will be 4 */

Hope it helps.

Marco, I just have to say how beautifully organized your answer is. I love that.

Marco Amadio
Marco Amadio
4,882 Points

Thank you! I'm glad to be of help :)

Oh thanks! So I did mixed them up xD

Thanks Marco!

Marco Amadio
Marco Amadio
4,882 Points

Channon, you're welcome ;)