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 Improve the Quiz – One Solution

There is SyntaxError: Unexpected token '['. const declared variable 'correct' must have an initializer.

Hello, in my code it's saying I have syntax error on line 8 which is this one, const correct[];

// 2. Store the number of questions answered correctly const correct[]; const incorrect[]; let correctAnswers = 0;

I have no idea what is wrong. Can somebody help me please?

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Tina Budzáková! It looks like you're missing a couple of equal signs. According to your question, you currently have:

const correct[]; 
const incorrect[];

But that should be:

const correct = []; 
const incorrect = [];

They should be initialized with empty arrays. The equals sign is the assignment operator.

Hope this helps! :sparkles:

Thank you! It's working.