Files

38 lines
660 B
Markdown
Raw Normal View History

2018-10-12 15:37:13 -04:00
---
title: Use Dot Notation to Access the Properties of an Object
---
# Use Dot Notation to Access the Properties of an Object
2018-10-12 15:37:13 -04:00
---
## Problem Explanation
2018-10-12 15:37:13 -04:00
The following code will simply print `1` from the `obj` object.
2018-10-12 15:37:13 -04:00
```javascript
let obj = {
property1: 1,
property2: 2
2018-10-12 15:37:13 -04:00
};
console.log(obj.property1);
```
Following this logic, use the `console.log` operation to print both `property1`and `property2`to the screen.
---
## Solutions
2018-10-12 15:37:13 -04:00
<details><summary>Solution 1 (Click to Show/Hide)</summary>
```javascript
2018-10-12 15:37:13 -04:00
let dog = {
name: "Spot",
numLegs: 4
};
// Add your code below this line
console.log(dog.name);
console.log(dog.numLegs);
```
</details>