--- id: 587d7dae367417b2b2512b7b title: Understand Own Properties localeTitle: Entender propiedades propias challengeType: 1 --- ## Description
En el siguiente ejemplo, el constructor de Bird define dos propiedades: name y numLegs :
function Bird(name) {
  this.name = name;
  this.numLegs = 2;
}

let duck = new Bird("Donald");
let canary = new Bird("Tweety");
name y numLegs se denominan propiedades own , porque se definen directamente en el objeto de instancia. Eso significa que el duck y el canary tienen su propia copia separada de estas propiedades. De hecho, cada instancia de Bird tendrá su propia copia de estas propiedades. El siguiente código agrega todas las propiedades own de duck a la matriz ownProps :
let ownProps = [];

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

console.log(ownProps); // prints [ "name", "numLegs" ]
## Instructions
Agrega las propiedades own de canary a la matriz ownProps .
## Tests
```yml tests: - text: ownProps debe incluir los valores "numLegs" y "name" . testString: 'assert(ownProps.indexOf("name") !== -1 && ownProps.indexOf("numLegs") !== -1, "ownProps should include the values "numLegs" and "name".");' - 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 Bird(name) { this.name = name; this.numLegs = 2; } let canary = new Bird("Tweety"); let ownProps = []; // Add your code below this line ```
## Solution
```js function Bird(name) { this.name = name; this.numLegs = 2; } let canary = new Bird("Tweety"); function getOwnProps (obj) { const props = []; for (let prop in obj) { if (obj.hasOwnProperty(prop)) { props.push(prop); } } return props; } const ownProps = getOwnProps(canary); ```