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 trialJunior Aidee
Front End Web Development Techdegree Graduate 14,657 PointsQuiz Question 2 (What is the correct answer?)
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 = [ , ];
5 Answers
Junior Aidee
Front End Web Development Techdegree Graduate 14,657 PointsThank you Abdi for your reply. I did google on how to combine the two arrays and I did find the answer that you provided to me but in this specific instance, it looks like the better solution was to use the spread operator to copy both arrays into the third array. That solved my challenge question. Thank you again for your reply.
Abdi Salad
8,078 PointsYou're welcome.
Kevin nguyen
Python Development Techdegree Student 1,643 PointsI agree in fact, abdi answer is wrong given the problem being asked. it has a comma but abdi answer ignore the comma
Paul Oketch
Front End Web Development Techdegree Graduate 13,544 PointsFor this problem, we use the spread operator(...) to join the two arrays.
const itemsA = [ 'Lightsaber', 'Mockingjay pin', 'Box of chocolates' ];
const itemsB = [ 'Ghost trap', 'The One Ring', 'DeLorean' ]
const allItems = [ ...itemsA , ...itemsB ];
Michael Hicks
24,208 PointsThis is the correct solution. Use the spread operator. This worked for me. thank you Paul Oketch
tundun
9,202 Points...itemsA, ...itemsB
Manoj Gurung
5,318 Pointsall the answers donot provide the real answer requested. We gotta change this.
Moise Ngoumape
15,862 Pointsthe answer will be ...itemsA, ...itemsB
Abdi Salad
8,078 PointsAbdi Salad
8,078 Points