2018-10-12 15:37:13 -04:00
|
|
|
---
|
|
|
|
title: Access Array Data with Indexes
|
|
|
|
---
|
2019-07-24 00:59:27 -07:00
|
|
|
# Access Array Data with Indexes
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
|
|
|
|
---
|
|
|
|
## Hints
|
|
|
|
|
|
|
|
### Hint 1
|
2018-10-12 15:37:13 -04:00
|
|
|
The first element of an array is at position zero. So, if you want to access the first element of an array, you can do it like so:
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
var arr = ["Programming", 123, "Coding", 789];
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
var firstElem = arr[0]; // This is "Programming"
|
|
|
|
var thirdElem = arr[2]; // This is "Coding"
|
|
|
|
var fourthElem = arr[3]; // This is 789
|
2018-10-12 15:37:13 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
Notice that the length of the array is 4, and the position of the last element of the array is 3.
|