Meet arrays, "expected ';'"


I'm not quite sure what I'm doing wrong, I tried to troubleshoot this for the last hour and can't seem to wrap my head around why the systems says, "Syntax error: expected ';' ". Any help will be much appreciated, thank you!

var junk ["Charles","James",3;4];


so the syntax for an array would be
var random ["thing one", "thing two", 1, 2]; with yours there is a ; instead of ,

there is no { } so you don't need them. your console.log is fine.


junk is a variable where you can assign array with different values. So you need to declare this variable and assign it with assign operator =:

var junk = ["Charles","James",3;4];

Also every element in an array should be separated by comma , but you used ; after 3.

We need to use_{ }_ with statements. So console.log() doesn't need them.


Thank you! I cannot believe how many small errors I am overlooking while learning my first language. I apologize to ask a question within another question, but is there a practice to minimize that? As in is there a way to become more aware of the small things while also keeping a bigger eye on the total project all together; or does that just come with experience and the work?


Practice makes perfect! :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.