-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcar.html
More file actions
49 lines (45 loc) · 904 Bytes
/
Copy pathcar.html
File metadata and controls
49 lines (45 loc) · 904 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Object references</title>
<script>
function findCarInLot(car) {
for (let i = 0; i < lot.length; i++) {
if (car === lot[i]) {
return i;
}
}
return -1;
}
let chevy = {
make: "Chevy",
model: "Bel Air"
};
let taxi = {
make: "Webville Motors",
model: "Taxi"
};
let fiat1 = {
make: "Fiat",
model: "500"
};
let fiat2 = {
make: "Fiat",
model: "500"
};
let lot = [chevy, taxi, fiat1, fiat2];
let loc1 = findCarInLot(fiat2);
let loc2 = findCarInLot(taxi);
let loc3 = findCarInLot(chevy);
let loc4 = findCarInLot(fiat1);
console.log("Car lot:", lot);
console.log("Location of fiat 2:", loc1);
console.log("Location of taxi:", loc2);
console.log("Location of chevy:", loc3);
console.log("Location of fiat 1:", loc4);
</script>
</head>
<body>
</body>
</html>