furthered work
This commit is contained in:
35
6/pets.html
Normal file
35
6/pets.html
Normal file
@ -0,0 +1,35 @@
|
||||
<html><body><script>
|
||||
function Cat(name) {
|
||||
this.name = name;
|
||||
}
|
||||
Cat.prototype.sayHello = function () {
|
||||
console.log(`Miaow! My name is ${this.name}.`);
|
||||
};
|
||||
|
||||
let kiki = new Cat("Kiki");
|
||||
kiki.sayHello();
|
||||
|
||||
class Dog {
|
||||
constructor(name) {
|
||||
this.name = name;
|
||||
}
|
||||
sayHello() {
|
||||
console.log(`Woof! My name is ${this.name}.`);
|
||||
}
|
||||
}
|
||||
|
||||
let felix = new Dog("Felix");
|
||||
|
||||
let moona = new Cat("Moona");
|
||||
moona.sayHello = function () {
|
||||
console.log(`HELLO!!! I'M ${this.name.toUpperCase()}!`);
|
||||
};
|
||||
moona.sayHello();
|
||||
|
||||
let yappy = new Dog("Yappy");
|
||||
yappy.sayHello = function (){
|
||||
console.log(`Bark Bark! I'M ${this.name.toUpperCase()}!`)
|
||||
}
|
||||
yappy.sayHello();
|
||||
felix.sayHello();
|
||||
</script></body></html>
|
Reference in New Issue
Block a user