--- id: 587d7dad367417b2b2512b78 title: Use a Constructor to Create Objects challengeType: 1 videoUrl: '' localeTitle: Usa un constructor para crear objetos --- ## Description
Aquí está el constructor de Bird del desafío anterior:
función Bird () {
this.name = "Albert";
this.color = "blue";
this.numLegs = 2;
// "esto" dentro del constructor siempre se refiere al objeto que se está creando
}

Deje que blueBird = new Bird ();
Observe que el new operador se utiliza al llamar a un constructor. Esto le dice a JavaScript que cree una nueva instance de Bird llamada blueBird . Sin el new operador, this dentro del constructor no apuntaría al objeto recién creado, dando resultados inesperados. Ahora blueBird tiene todas las propiedades definidas dentro del constructor de Bird :
blueBird.name; // => Albert
blueBird.color; // => azul
blueBird.numLegs; // => 2
Al igual que cualquier otro objeto, se puede acceder y modificar sus propiedades:
blueBird.name = 'Elvira';
blueBird.name; // => Elvira
## Instructions
Usa el constructor Dog de la última lección para crear una nueva instancia de Dog , asignándola a un hound variable.
## Tests
```yml tests: - text: hound debe ser creado usando el constructor de Dog . testString: 'assert(hound instanceof Dog, "hound should be created using the Dog constructor.");' - text: Tu código debe usar el new operador para crear una instance de Dog . testString: 'assert(code.match(/new/g), "Your code should use the new operator to create an instance of Dog.");' ```
## Challenge Seed
```js function Dog() { this.name = "Rupert"; this.color = "brown"; this.numLegs = 4; } // Add your code below this line ```
## Solution
```js // solution required ```