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.