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 Multidimensional Arrays Review JavaScript Arrays

Tai Software
Tai Software
2,335 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

Tai Software
Tai Software
2,335 Points

Nvm figured this out.

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