Stuck on the Record Collection lesson

I don’t learn as well through written instruction, so please excuse me if the answer is right in front of me, sometimes I’ll miss something entirely too obvious.

With that said, I’m not sure where to even begin with this one.
Based off of the third sentence on the lesson ( If prop isn’t "tracks" and value isn’t empty ( "" ), update or set the value for that record album’s property.), I’ve written this out:

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

I think I’m mostly just missing how I get from A to B. I know that if someone puts in something new, it needs to append it to the collection object. I also know that if somebody puts in something that contradicts information that is already there, then it needs to simply change it.
I just don’t understand how I’m supposed to do that.

I’ll go ahead and drop the entire problem here so that nobody has to go searching for it.

You are given a JSON object representing a part of your musical album collection. Each album has several properties and a unique id number as its key. Not all albums have complete information.

Write a function which takes an album’s id (like 2548 ), a property prop (like "artist" or "tracks" ), and a value (like "Addicted to Love" ) to modify the data in this collection.

If prop isn’t "tracks" and value isn’t empty ( "" ), update or set the value for that record album’s property.

Your function must always return the entire collection object.

There are several rules for handling incomplete data:

If prop is "tracks" but the album doesn’t have a "tracks" property, create an empty array before adding the new value to the album’s corresponding property.

If prop is "tracks" and value isn’t empty ( "" ), push the value onto the end of the album’s existing tracks array.

If value is empty ( "" ), delete the given prop property from the album.

Hints
Use bracket notation when link redacted.

Push is an array method you can read about on link redacted).

You may refer back to link redacted Introducing JavaScript Object Notation (JSON) for a refresher.

So it wasn’t what I missed… it was a caveat of the problem that I assumed was there but actually isn’t.
I figured the ID could be a random variable, and if it wasn’t something that matched a value in the collection object then it would have to be added.

Now that I realize that isn’t the case this should be easier for me to figure out. I’m going to try my hand at it again. Also thank you for the algorithm tip, makes it much easier to visualize what I’m doing in the code instead of just blindly editing.

I’m sure I’ll be right back whether I get it wrong again or not, at very least to provide what I was missing for anyone else that gets hung up on this lesson in the future.

I deleted my previous reply because I noticed a few things I’d done incorrectly.

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

I see. I’ll continue looking at it. I’ve been stuck on this for far too long, getting pretty frustrating to be quite honest.

So would the proper thing to do be
delete collection.id[prop]? because I kept getting undefined errors all yesterday no matter which way I tried to do this.

I just took a look at the lesson you linked me to and
var gloveBoxContents = myStorage.car.inside["glove box"]; was the answer for it, and maybe I’m incorrect but when I tried this yesterday in a very similar fashion it didn’t work. I’ll try it again like that and see if there was a typo or something like that.