Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Arrays Multidimensional Arrays Review JavaScript Arrays

Michael Rushton
Michael Rushton
4,157 Points

I can't get the answer to this quiz question.

Say you have two arrays, itemsA and itemsB, and you want to combine them into a new array named allItems. Complete the code so that the new allItems array stores the elements from itemsA first, followed by the elements inside itemsB:

const itemsA = [ 'Lightsaber', 'Mockingjay pin', 'Box of chocolates' ]; const itemsB = [ 'Ghost trap', 'The One Ring', 'DeLorean' ] const allItems = [ , ];

Im supposed to fill in the last gap in the allitems array but i haven't got a clue.

2 Answers

Steven Parker
Steven Parker
210,424 Points

You can create an expression that represents all the elements of an array by preceeding the array name with the spread operator.

:point_right: ...