Meet arrays, "expected ';'"


#1

https://www.codecademy.com/en/courses/javascript-beginner-en-NhsaT/2/1?curriculum_id=506324b3a7dffd00020bf661#


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];
{
    console.log(junk);
}


#2

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.


#3

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.


#4

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?


#5

Practice makes perfect! :slight_smile:


#6

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