2018-09-30 23:01:58 +01:00
---
id: 587d7dac367417b2b2512b74
title: Use Dot Notation to Access the Properties of an Object
challengeType: 1
2019-08-05 09:17:33 -07:00
forumTopicId: 301333
2018-09-30 23:01:58 +01:00
---
## Description
< section id = 'description' >
The last challenge created an < code > object< / code > with various < code > properties< / code > , now you'll see how to access the values of those < code > properties< / code > . Here's an example:
2019-05-17 06:20:30 -07:00
```js
let duck = {
name: "Aflac",
numLegs: 2
};
console.log(duck.name);
// This prints "Aflac" to the console
```
2018-09-30 23:01:58 +01:00
Dot notation is used on the < code > object< / code > name, < code > duck< / code > , followed by the name of the < code > property< / code > , < code > name< / code > , to access the value of "Aflac".
< / section >
## Instructions
< section id = 'instructions' >
2019-05-20 16:11:17 -07:00
Print both < code > properties< / code > of the < code > dog< / code > object to your console.
2018-09-30 23:01:58 +01:00
< / section >
## Tests
< section id = 'tests' >
```yml
2018-10-04 14:37:37 +01:00
tests:
2019-02-26 08:54:06 +05:30
- text: Your code should use < code > console.log</ code > to print the value for the < code > name</ code > property of the < code > dog</ code > object.
testString: assert(/console.log\(.*dog\.name.*\)/g.test(code));
- text: Your code should use < code > console.log</ code > to print the value for the < code > numLegs</ code > property of the < code > dog</ code > object.
testString: assert(/console.log\(.*dog\.numLegs.*\)/g.test(code));
2018-09-30 23:01:58 +01:00
```
< / section >
## Challenge Seed
< section id = 'challengeSeed' >
< div id = 'js-seed' >
```js
let dog = {
name: "Spot",
numLegs: 4
};
// Add your code below this line
```
< / div >
< / section >
## Solution
< section id = 'solution' >
```js
let dog = {
name: "Spot",
numLegs: 4
};
console.log(dog.name);
console.log(dog.numLegs);
```
< / section >