We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 8b55054 + dce645a commit 25df46cCopy full SHA for 25df46c
Roadmap/09 - HERENCIA/javascript/7R0N1X.js
@@ -0,0 +1,44 @@
1
+class Animal {
2
+
3
+ constructor(nombre) {
4
+ this.nombre = nombre
5
+ }
6
7
+ sonido() {
8
+ return `${this.nombre} hace un sonido.`
9
10
+}
11
12
+class Perro extends Animal {
13
14
15
+ super(nombre)
16
17
18
19
+ return `${this.nombre} ladra: ¡Guau guau!`
20
21
22
23
24
+class Gato extends Animal {
25
26
27
28
29
30
31
+ return `${this.nombre} maúlla: ¡Miau miau!`
32
33
34
35
36
+function imprimirSonido(animal) {
37
+ return animal.sonido();
38
39
40
+const miPerro = new Perro("Rex")
41
+const miGato = new Gato("Mimi")
42
43
+console.log(imprimirSonido(miPerro))
44
+console.log(imprimirSonido(miGato))
0 commit comments