-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdogmod.html
More file actions
47 lines (39 loc) · 912 Bytes
/
Copy pathdogmod.html
File metadata and controls
47 lines (39 loc) · 912 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Modifying dogs made from the Dog class</title>
<script>
class Dog {
constructor(name, breed, weight) {
this.name = name;
this.breed = breed;
this.weight = weight;
}
bark() {
if (this.weight > 25) {
console.log(`${this.name} says Woof!`);
} else {
console.log(`${this.name} says Yip!`);
}
}
}
// Dogs
let fido = {name: "Fido", breed: "Mixed", weight: 38};
let rover = new Dog("Rover", "German Shephard", 90);
let spot = new Dog("Spot", "Chihuahua", 10);
fido.owner = "Bob";
delete fido.weight;
fido.trust = function(person) {
return (person === "Bob");
};
console.log(`Does Fido trust Bob? ${fido.trust("Bob")}`);
let notBite = fido.trust("Bob");
console.log(`Will Fido bite Bob? ${notBite}`);
notBite = spot.trust("Bob");
console.log(`Will Spot bite Bob? ${notBite}`);
</script>
</head>
<body>
</body>
</html>