# Record Collection challenge accessing nested object properties

**URL:** <https://forum.freecodecamp.org/t/record-collection-challenge-accessing-nested-object-properties/7616>\
**Category:** General\
**Created:** [June 3, 2016, 4:38pm UTC](https://forum.freecodecamp.org/t/record-collection-challenge-accessing-nested-object-properties/7616 "2016-06-03T16:38:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![palmaone](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/palmaone/32/193494_2.png) [@palmaone](https://forum.freecodecamp.org/u/palmaone)\
**Post date:** [June 3, 2016, 4:38pm UTC](https://forum.freecodecamp.org/t/record-collection-challenge-accessing-nested-object-properties/7616/1 "2016-06-03T16:38:26Z")

</div>

[https://www.freecodecamp.com/challenges/record-collection](https://www.freecodecamp.com/challenges/record-collection)

I am confused about how to reference a nested property inside an object using variables. In the challenge we are given three variables as inputs to the function, however when trying to reference the property I just get undefined when using chained dot and bracket notation… How are we supposed to reference a nested property using variables?

---

<div class="post-metadata">

**Author:** ![BenGitter](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/bengitter/32/12192_2.png) [@BenGitter](https://forum.freecodecamp.org/u/BenGitter)\
**Post date:** [June 3, 2016, 4:50pm UTC](https://forum.freecodecamp.org/t/record-collection-challenge-accessing-nested-object-properties/7616/2 "2016-06-03T16:50:26Z")

</div>

Hey, you can’t use dot notation with variables. You can use: collection[id][prop] to acces a property.

---

<div class="post-metadata">

**Author:** ![chuckadams](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/chuckadams/32/109651_2.png) [@chuckadams](https://forum.freecodecamp.org/u/chuckadams)\
**Post date:** [June 3, 2016, 6:06pm UTC](https://forum.freecodecamp.org/t/record-collection-challenge-accessing-nested-object-properties/7616/3 "2016-06-03T18:06:45Z")

</div>

> [@BenGitter](#):
>
> Hey, you can’t use bracket notation with variables.

In what sense? One of the main reasons to use bracket notation is to index using a variable, e.g. `foo[bar]`. If you meant something more specific, please reflect that in your explanation.

---

<div class="post-metadata">

**Author:** ![BenGitter](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/bengitter/32/12192_2.png) [@BenGitter](https://forum.freecodecamp.org/u/BenGitter)\
**Post date:** [June 3, 2016, 6:12pm UTC](https://forum.freecodecamp.org/t/record-collection-challenge-accessing-nested-object-properties/7616/4 "2016-06-03T18:12:17Z")

</div>

I’m sorry. I confused the two. I meant dot notation. Bracket notation is indeed used for variables. Thanks for noticing, I edited my post.

---

<div class="post-metadata">

**Author:** ![AbdiViklas](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/abdiviklas/32/95315_2.png) [@AbdiViklas](https://forum.freecodecamp.org/u/AbdiViklas)\
**Post date:** [October 8, 2016, 11:30am UTC](https://forum.freecodecamp.org/t/record-collection-challenge-accessing-nested-object-properties/7616/5 "2016-10-08T11:30:06Z")

</div>

This thread is old, but in case somebody comes here, like me, having encountered this issue: I found [this Medium article about dot notation vs bracket notation](https://medium.com/@prufrock123/js-dot-notation-vs-bracket-notation-797c4e34f01d#.iy8j4siop) really helpful.

---

<div class="post-metadata">

**Author:** ![jwilkins.oboe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwilkins.oboe/32/179497_2.png) [@jwilkins.oboe](https://forum.freecodecamp.org/u/jwilkins.oboe)\
**Post date:** [January 16, 2021, 5:30am UTC](https://forum.freecodecamp.org/t/record-collection-challenge-accessing-nested-object-properties/7616/6 "2021-01-16T05:30:19Z")

</div>

Closed on January 16, 2021, 5:30am UTC


