Basic JavaScript - Access Array Data with Indexes

Tell us what’s happening:
Describe your issue in detail here.

Your code so far
i don’t no how did they work

const myArray = [50, 60, 70];
const myData = array[1];

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Basic JavaScript - Access Array Data with Indexes

Link to the challenge:

“…set it to equal the first value of myArray

“…arrays use zero-based indexing, so the first element in an array has an index of 0.”

So what number would use use to get the first value in an array? That’s the number you want to use in the solution. You actually did this correctly in your console.log. You just need to do it correctly when setting myData.

Ahh, I just noticed that you used the correct index number in your console.log, but you didn’t use the correct variable. Remember, if you want to access a value in myArray then you need to use bracket notation on myArray.

I don’t understand what you mean, what are you trying to solve and what should be the response of this cod

most of the programming language start 0 as 1 so the first letter of a string or an array use 0 as 1 in this code “myArray” has 3 values in it so the first one is 50 and second 60 and the third 70 so if you write myArray[0] that means you are calling the first value in the array which is “50” and so on but hear you first display the my data and than assign it a value think you did not do homework and showing your teacher before doing it
const myArray = [50, 60, 70]; //an array with 3 numbers
const myData = myArray[1]; // assing the value 60 to a variable called myData
console.log(myData); //display the value of the variable
and array[2 ] is a function to give you the index value it can not use on a number

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