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 Arrays Store Multiple Values in an Array Add Elements to an Array

Next, add two names to the beginning of the array using the unshift() array method. The final array should have eight na

I dont know what i did wrong

script.js
var guestList = ['Sandra', 'Omar', 'Magnus', 'Becky'];
guestList.push('Mars', 'Mary');
guestList.unshift('Alex', 'Jason', 'David');
Julian Addison
Julian Addison
13,302 Points

You're using the unshift method properly. What you've done wrong is that you've added three new names to the array. Just remove 'David' from the method call. The result of the second task is that the array needs 8 names, and your array has 9 once the code runs.

var guestList = ['Sandra', 'Omar', 'Magnus', 'Becky']; guestList.push('Mars', 'Mary'); guestList.unshift('Alex', 'Jason' );

1 Answer

Tom Nguyen
Tom Nguyen
33,500 Points

my solution:

script.js
const guestList = ['Eleven', 'Dustin', 'Lucas', 'Will'];
guestList.push('new_guest_1','new_guest_2');
guestList.unshift('add_to_beginning_1', 'add_to_beginning_2');