[DONE] 10/13 junkData Error


#1

I Don't Understand What I'm Doing Wrong, It Keeps Coming Up With Oops, try again. Careful! Array elements start at 0, so junkData[4] is off the end of the array--it's not the fourth element.
So What Am I Post To Do?

  • Here's The Code For What I Have:

var junkData = ["Eddie Murphy", 49, "peanuts", 31];
console.log(junkData[4])


#2

Array elements start from index 0, not from 1
for example:

var array2 = [a, b, c, d, e];

so in the array the first element is "a" with index of 0, the fifth element is "e" with index on 4


#3

I'm Not Following....


#4

You need to change your thought process just a little bit.

Usually, we look at a list and we count them as "1, 2, 3, etc, etc".

In Javascript, we need to change that thought process and start counting from zero. So if you look at a list now, start counting it as "0, 1, 2, 3, etc, etc".

So using Voluncss array above as if it were a list:
Instead of reading it as
1. a
2. b
3. c
4. d

it would read as:
0. a
1. b
2. c
3. d

Hopefully that didn't confuse you more. Learning array numbering for the first time can be a bit confusing. But once you have it down, it comes as second nature.


#5

remember that counting in javascript starts at 0 not one so technically there are only 3 in this example. I tried this and it work perfectly.

var junkData = ["Eddie Murphy", 49, "peanuts", 31];
{ console.log(junkData[3]);}