JAVA
[자바 스크립트] 데이터 타입 - 배열
코린이도이
2023. 10. 23. 21:36
1. var를 사용하여 변수 fruit을 선언하고, 배열 데이터 타입인 ["Apple", "Banana"] 데이터를 삽입합니다.
2. document.write();를 사용하여 fruit의 데이터를 확인합니다.
3. document.write(fruit[0]);를 입력하여, fruit의 배열에서 첫 번째 데이터가 무엇인지 확인합니다.
4. fruit 배열의 첫 번째 데이터를 "Tomato"로 변경합니다.
5. document.write();를 사용하여 데이터가 올바르게 변경됐는지 확인합니다.
var fruit = ["Apple", "Banana"];
document.write(fruit);
document.write(fruit[0]); //Apple 출력
fruit[0] = "Tomato";
document.write(fruit);