-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectArray.js
More file actions
49 lines (46 loc) · 994 Bytes
/
ObjectArray.js
File metadata and controls
49 lines (46 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
var cars = [];
var car01 = {
name : "sonata",
ph : "500ph",
start : function () {
console.log("engine is starting");
},
stop : function () {
console.log("engine is stoped");
}
}
var car02 = {
name : "BMW",
ph : "600ph",
start : function () {
console.log("engine is starting");
},
stop : function () {
console.log("engine is stoped");
}
}
var car03 = {
name : "Fiat",
ph : "200ph",
start : function () {
console.log("engine is starting");
},
stop : function () {
console.log("engine is stoped");
}
}
cars[0] = car01;
cars[1] = car02;
cars[2] = car03;
console.log(cars[0]);
console.log(cars[1]);
console.log(cars[2]);
// 자동차 배열 안에 BMW라는 이름의 차가 있다면 'Find!'라는 문자열 출력
// for, if 사용
console.log('-----work1-----');
for (i = 0; i < cars.length; i++) {
//console.log(cars[i].name);
if (cars[i].name == 'BMW') {
console.log('Find!');
}
}