[wecode/pre/Replit] 07. Array - 03. 배열 요소 접근
2022. 10. 4. 11:03ㆍpre-JS-Replit
Read.me
# 03. 배열 요소 접근
우리는 인덱스(index)를 사용해 배열 안의 데이터에 접근할 수 있습니다.
```js
let array = [50,60,70];
array[0]; // equals 50
array[1]; // equals 60
```
# Assignment
- 변수 firstValue를 선언해주세요.
- firstValue의 값은 배열 myArray의 첫 번째 값입니다.
index.js
function arrayIndex() {
// do not change your code here
const myArray = [50, 60, 70];
// write your code below
let firstValue = myArray[0];
// do not change your code here
return firstValue;
}
console.log(arrayIndex())
module.exports = { arrayIndex }
▶ 배열의 순서
▷ let myArray = ['가', '나', '다', '라'];
myArray[0] = '가'
myArray[1] = '나'
myArray[2] = '다'
myArray[3] = '라'
배열의 순서는 0부터 !!
console
50
'pre-JS-Replit' 카테고리의 다른 글
[wecode/pre/Replit] 07. Array - 05. 다차원배열 접근 (0) | 2022.10.04 |
---|---|
[wecode/pre/Replit] 07. Array - 04. 배열 요소 수정 (1) | 2022.10.04 |
[wecode/pre/Replit] 07. Array - 02. 배열 안의 배열 (0) | 2022.10.04 |
[wecode/pre/Replit] 07. Array - 01. 배열에 데이터 저장하기 (0) | 2022.10.04 |
[wecode/pre/Replit] 07. Array - 00. Array Intro (0) | 2022.10.04 |