--- id: 587d7daf367417b2b2512b7d title: Iterate Over All Properties localeTitle: Iterar sobre todas las propiedades challengeType: 1 --- ## Description
Ahora ha visto dos tipos de propiedades: propiedades own y propiedades de prototype . Own propiedades Own se definen directamente en la instancia del objeto en sí. Y las propiedades del prototype se definen en el prototype .
function Bird(name) {
  this.name = name; //own property
}

Bird.prototype.numLegs = 2; // prototype property

let duck = new Bird("Donald");
Así es como se agregan duck's propiedades own duck's a la matriz ownProps y las propiedades de prototype a la matriz prototypeProps :
let ownProps = [];
let prototypeProps = [];

for (let property in duck) {
  if(duck.hasOwnProperty(property)) {
    ownProps.push(property);
  } else {
    prototypeProps.push(property);
  }
}

console.log(ownProps); // prints ["name"]
console.log(prototypeProps); // prints ["numLegs"]
## Instructions
Agregue todas las propiedades own de beagle a la matriz ownProps . Agregue todas las propiedades prototype de Dog a la matriz prototypeProps .
## Tests
```yml tests: - text: La matriz ownProps debe incluir "name" . testString: 'assert(ownProps.indexOf("name") !== -1, "The ownProps array should include "name".");' - text: La matriz prototypeProps debe incluir "numLegs" . testString: 'assert(prototypeProps.indexOf("numLegs") !== -1, "The prototypeProps array should include "numLegs".");' - text: Resuelva este desafío sin usar el método Object.keys() . testString: 'assert(!/\Object.keys/.test(code), "Solve this challenge without using the built in method Object.keys().");' ```
## Challenge Seed
```js function Dog(name) { this.name = name; } Dog.prototype.numLegs = 4; let beagle = new Dog("Snoopy"); let ownProps = []; let prototypeProps = []; // Add your code below this line ```
## Solution
```js function Dog(name) { this.name = name; } Dog.prototype.numLegs = 4; let beagle = new Dog("Snoopy"); let ownProps = []; let prototypeProps = []; for (let prop in beagle) { if (beagle.hasOwnProperty(prop)) { ownProps.push(prop); } else { prototypeProps.push(prop); } } ```