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

Kyle Wang
Kyle Wang
1,834 Points

Can't use the flat method on the outside. itemsA.concat(itemsB) doesn't work. What am I missing?

Question 2 Quiz.

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

List of possible answers below.

const allItems = itemsA.concat(itemsB) const allItems = [itemsA,itemsB].flat()

I just don't get it. Nothing I attempt seems to work. The comma really throws me off and the fact you're only able to do two entries with a comma.

I don't believe this is a solution but I also attempted below.

const allItems = [itemsA, itemsB]

1 Answer

Kyle Wang
Kyle Wang
1,834 Points

Nvm figured this out.

const allItems = [ ...itemsA , ...itemsB ]