Record Collection Collection[id][prop] - Solved

Hi, Im trying to complete this updateRecords function, but then im in stuck figuring out the collection[id][prop] from the spoiler. It work prefectly without any error, but when i tried to do the same with the Accessing Nested Objects tutorial, it’s returning an error message “error: Uncaught TypeError: Cannot read property ‘outside’ of undefined”.
Can Anyone tell me How the collection[id][prop] work?

Accessing Nested Objects Tutorial

// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
    "outside": {
      "trunk": "jack"
    "234": {
      "outside": "hello"
myStorage[234]["outside"]; // this line returning an error

Record Collection

// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "Little Red Corvette" 
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    "5439": {
      "album": "ABBA Gold"
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  if (prop === "tracks" && value !== "") {
   if(collection[id][prop]) {
   else {
  } else if (value !== "") {
    collection[id][prop] = value;
  } else {
    delete collection[id][prop];

  return collection;

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");

Link to the challenge:

You’re missing a level of depth here. The property 234 is not at the root level of myStorage - instead, it’s inside the car property. So you could do myStorage['car'][234]['outside'], or myStorage['car']['outside'], as you have an outside property at both levels.

As to collection[id][prop], we are passing in two parameters, id and prop. If we use collection[id], then we are finding a property of collection that has id as its property name.

If we wanted, we could do const myRecord = collection[id]; and save the reference to that particular record. It’s still in the collection, but this makes a convenient way to get to it.

Then collection[id][prop] (or, using our handy-dandy shorthand, myRecord[prop]) drills into that particular record Object, and accesses the property named whatever value we passed into prop.

How i didn’t notice that XD. Thank you for solving the problem.

With objects, it can be easy to get confused when sub-objects and stuff keep growing more and more complex. It happens.