Files

30 lines
780 B
Markdown
Raw Normal View History

2018-10-12 15:37:13 -04:00
---
title: Understand Own Properties
---
# Understand Own Properties
2018-10-12 15:37:13 -04:00
---
## Problem Explanation
2018-10-12 15:37:13 -04:00
In the example code given you will see a new array `ownProps[]` intialised followed by a `for...in` statement to loop through the properties of `duck` and then use a `push()` statement to fill in the new array. The same method must be followed for the `canary` object.
Simply replace the `duck` object in the 'for...in' statement with the `canary`object to pass all test cases.
---
## Solutions
<details><summary>Solution 1 (Click to Show/Hide)</summary>
2018-10-12 15:37:13 -04:00
```javascript
2018-10-12 15:37:13 -04:00
let canary = new Bird("Tweety");
let ownProps = [];
// Add your code below this line
for (let property in canary) {
if (canary.hasOwnProperty(property)) {
2018-10-12 15:37:13 -04:00
ownProps.push(property);
}
}
```
</details>