Tell us what’s happening:
I’m understanding the problem. I just want to see a visual example of array index use versus bracket notation string use. How do I differentiate the use if they are super similar in anyones opinion?
Your code so far
// Setup
var myArray = [50,60,70];
// Only change code below this line
myArray[0];
var myData = myArray[0];
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36.
do you mean between accessing an array and an object?
it looks the same
var arr = [33, 44, 55];
var index = 2;
console.log(arr[index]); // 55
var obj = {name: "ieahleen", status: "moderator"};
var prop = "name";
console.log(obj[prop]); // name
Like I understand that array indexes specify the first entry (in this case its 50) but when it’s not an array indexe being specified using the [0] to get 50. How would I understand when it only looks at the 5 that is in the 50 when im NOT using array indexes. I hope I summed it a little better.
Do you mean if you had the string “506070”?
A string, under the covers, is an array of single characters (with extra bells and whistles). You can access those individual characters by index, but “50” is two characters, so index 0 is just “5”.
Yup. If you are ever given a string and you need to get at a “chunk” of it, there are different ways to do that depending on what the string looks like and what sort of “chunk” you need.