Access Array Data with Indexes

Tell us what’s happening:

I watched an FCC Youtube video and had the exact line: “var myData = myArray [0];”

I get this right: “The variable myData should equal the first value of myArray.”

But, I get this wrong:
“The data in variable myArray should be accessed using bracket notation.”

Your code so far

// Example
var ourArray = [1,2,3];
var ourData = ourArray[0]; // equals 1

// Setup
var myArray = [1,2,3];

// Only change code below this line.
var myData = myArray [0]; 

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Safari/604.1.38.

Link to the challenge:

It looks like you might have a space before your brackets?

2 Likes

quest: Create a variable called myData and set it to equal the first value of myArray using bracket notation.

so first we creat a variable like we did before

var myData = ;

Then as we can make out of the example above

var data = array[1]; 

as they explain the 1 equals 60 because its the second value in the string.
sinds we are using zeroindexing
[50,60,70];
^ ^ ^
0 1 2
so it becomes

var myData = myArray[0];