diff --git a/curriculum/challenges/spanish/02-javascript-algorithms-and-data-structures/object-oriented-programming/add-methods-after-inheritance.spanish.md b/curriculum/challenges/spanish/02-javascript-algorithms-and-data-structures/object-oriented-programming/add-methods-after-inheritance.spanish.md
index 701498c209..4e158c35f5 100644
--- a/curriculum/challenges/spanish/02-javascript-algorithms-and-data-structures/object-oriented-programming/add-methods-after-inheritance.spanish.md
+++ b/curriculum/challenges/spanish/02-javascript-algorithms-and-data-structures/object-oriented-programming/add-methods-after-inheritance.spanish.md
@@ -7,7 +7,7 @@ localeTitle: Añadir métodos después de la herencia
---
## Description
- Una función constructora que hereda su objeto prototype
de una función constructora de supertype
aún puede tener sus propios métodos además de los métodos heredados. Por ejemplo, Bird
es un constructor que hereda su prototype
de Animal
: función animal () {}
Animal.prototype.eat = function () {
console.log ("nom nom nom");
};
función Bird () {}
Bird.prototype = Object.create (Animal.prototype);
Bird.prototype.constructor = Bird;
Además de lo que se hereda de Animal
, desea agregar un comportamiento que sea exclusivo de los objetos Bird
. Aquí, Bird
obtendrá una función fly()
. Las funciones se agregan al prototype
Bird's
la misma manera que cualquier función de constructor: Bird.prototype.fly = function () {
console.log ("Estoy volando!");
};
Ahora las instancias de Bird
tendrán los métodos de eat()
y fly()
: dejar pato = nuevo pájaro ();
duck.eat (); // imprime "nom nom nom"
duck.fly (); // impresiones "Estoy volando!"
+ Una función constructora que hereda su objeto prototype
de una función constructora de supertype
aún puede tener sus propios métodos además de los métodos heredados. Por ejemplo, Bird
es un constructor que hereda su prototype
de Animal
: function animal () {}
Animal.prototype.eat = function () {
console.log ("nom nom nom");
};
function Bird () {}
Bird.prototype = Object.create (Animal.prototype);
Bird.prototype.constructor = Bird;
Además de lo que se hereda de Animal
, desea agregar un comportamiento que sea exclusivo de los objetos Bird
. Aquí, Bird
obtendrá una función fly()
. Las funciones se agregan al prototype
Bird's
la misma manera que cualquier función de constructor: Bird.prototype.fly = function () {
console.log ("Estoy volando!");
};
Ahora las instancias de Bird
tendrán los métodos de eat()
y fly()
: dejar pato = nuevo pájaro ();
duck.eat (); // imprime "nom nom nom"
duck.fly (); // impresiones "Estoy volando!"
## Instructions
Agregue todo el código necesario para que el objeto Dog
hereda de Animal
y el constructor Dog's
prototype
Dog's
esté configurado en Dog. Luego, agregue un método de bark()
al objeto Dog
para que el beagle
pueda eat()
y bark()
. El método de la bark()
debe imprimir "¡Guau!" a la consola.
@@ -67,6 +67,18 @@ beagle.bark(); // Should print "Woof!"
```js
-// solution required
+function Animal() { }
+Animal.prototype.eat = function() { console.log("nom nom nom"); };
+
+function Dog() { }
+Dog.prototype = Object.create(Animal.prototype);
+Dog.prototype.constructor = Dog;
+Dog.prototype.bark = function () {
+ console.log('Woof!');
+};
+let beagle = new Dog();
+
+beagle.eat();
+beagle.bark();
```