--- id: 587d7dad367417b2b2512b78 title: Use a Constructor to Create Objects localeTitle: Usa un constructor para crear objetos challengeType: 1 --- ## Description
Aquí está el constructor Bird del desafío anterior:
function Bird() {
  this.name = "Albert";
  this.color = "blue";
  this.numLegs = 2;
  // "this" inside the constructor always refers to the object being created
}

let 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 Bird :
blueBird.name; // => Albert
blueBird.color; // => blue
blueBird.numLegs; // => 2
Al igual que cualquier otro objeto, sus propiedades se pueden acceder y modificar:
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 function Dog() { this.name = "Rupert"; this.color = "brown"; this.numLegs = 4; } const hound = new Dog(); ```