furthered work

This commit is contained in:
2024-10-03 11:29:13 -05:00
parent fa7ac2949b
commit 1e756f4f72
15 changed files with 301 additions and 93 deletions

35
6/pets.html Normal file
View 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>