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 Copy and Combine Arrays with the Spread Operator

Jelena Feliciano
seal-mask
.a{fill-rule:evenodd;}techdegree
Jelena Feliciano
Full Stack JavaScript Techdegree Student 12,729 Points

I am getting a syntax error stating Missing initializer in const declaration but I did it the way the teacher shows.

const middle = ['lettuce', 'cheese', 'patty']; const burger = ['top bun', ...middle, 'bottom bun'];

const brass = ['trumpet', 'trombone', 'French horn', 'baritone', 'tuba']; const woodwind = ['flute', 'oboe', 'clarinet', 'saxophone', 'basoon']; const instruments = [ ...brass, ...woodwind ],

console.log(instruments);

2 Answers

const middle = ['lettuce', 'cheese', 'patty']; 
const burger = ['top bun', ...middle, 'bottom bun'];

const brass = ['trumpet', 'trombone', 'French horn', 'baritone', 'tuba']; 
const woodwind = ['flute', 'oboe', 'clarinet', 'saxophone', 'basoon']; 

const instruments = [ ...brass, ...woodwind ], // ERROR HERE COMMA AT END

console.log(instruments);

You have placed a comma instead of a semi-colon at end of the const instruments.

Change the comma to a semi colon when creating the instruments array const instruments = [ ...brass, ...woodwind ],