Record Collection object iteration

Tell us what’s happening:
Hello everyone,
I am having trouble solving the exercise “Record Collection”,
please see my code so far and suggest me corrections/ improvements
without telling me the solution!
thank you so much for your help!

Your code so far


// 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": [ //if prop is "tracks" and value isn't empty (""), push the value onto the end of the album's existing tracks array.
        "1999", 
        "Little Red Corvette"  
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ] //If value is empty (""), delete the given property from the album.
    },
    "5439": {
      "album": "ABBA Gold"
      // no tracks prop: create an empty array before adding the new value to the album's corresponding property.
    }
};
// 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) {

var id = collection[""]; //var id will receive the id parameter to look for in collection object

  for (var id in collection) {

    if (value !== "") {   // if prop/key does not exist(empty string)
      collection.id.prop[value];   //set its value
    }

    else if (prop == "tracks" && value !== ""){    //If the prop parameter is equal to "tracks" //and the value isn’t an empty string, push the value onto the end of the tracks array.
      collection.id.prop.push[value];
    }
    
    else if (value == "" ) {
      delete collection.id.prop[""]; // if value is empty delete its prop
    }

    else {
      return collection;
    }
  }
}

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


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Firefox/68.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/record-collection

can you explain this line a bit more? I’m not sure i understand the comment.

Hi Michael!
var id refers to the 1st level of numbers that hold each album data,
example: “2548”, “2468”, “1245” or “5439”.