-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcargame.html
More file actions
72 lines (50 loc) · 1.53 KB
/
cargame.html
File metadata and controls
72 lines (50 loc) · 1.53 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="UTF-8">
<title>My First Object</title>
</head>
<body>
<script>
var car = {
make: "Honda",
model: "Fit",
color: "Blue Raspberry",
mileage: 3000,
isWorking: true,
driveToWork: function() {
alert("Old Mileage: " + this.mileage);
this.mileage = this.mileage + 8;
alert("New mileage: " + this.mileage);
},
driveAroundWorld: function() {
alert("Old Mileage: " + this.mileage);
this.mileage = this.mileage + 24000;
alert("New Mileage: " + this.mileage);
alert("Car needs a tuneup!");
this.isWorking = false;
},
getTuneUp: function() {
alert("Car is ready to go!");
this.isWorking = true;
},
honk: function() {
alert("Honk! Honk!");
}
};
// How would we log... console.log("")
// The car's make? honda
console.log("car make: " + car.make);
// The car's model? fit
console.log("car model: " + car.model);
// The car's mileage? 3000
console.log("car mileage: " + car.mileage);
// How would we run the car's driveToWork method? car.driveToWork
car.driveToWork();
// How would we run the car's driveAroundWorld method? car.driveAroundWorld
car.driveAroundWorld();
// How would we run the getTuneUp method? car.getTuneUp
car.getTuneUp();
</script>
</body>
</html>