Help on the record collection challenge

I can’t get this to update the nested array properly. I’ve tried several iterations. Each of the following satisfied all but one of the requirements (different requirement that didn’t work):

function updateRecords(id, prop, value) {
  if(!collection[id][prop])
        collection[id][prop] = [];
    collection[id][prop].push(value);
  if (prop != "tracks" && value === "")
    {
      alert(collection[id][prop]);
      delete collection[id][prop];
    }
  
  if (prop === "artist" && value !== "")
    {
    collection[id].artist = value;
     
    }
  if(prop === "artist" && value === "")
    {
      delete collection[id][prop];
    }
  else if(prop == "album")
    {
      collection[id].album = value;
    }
  
  else if(prop === "tracks" && value === "")
    {
      delete collection[id].tracks;
    }
  

  return collection;
}

---OR---

function updateRecords(id, prop, value) {
  if (!(collection.hasOwnProperty("<tracks>")) && prop ==="tracks")
    {
      collection.tracks = [];
    }
  if (prop === "tracks" && value !== "")
    {
       collection[id][prop].push(value);
    }
  else if (prop === "tracks" && value === "")
    {
      delete collection[id][prop];
    }
  else if (prop === "artist")
    {
      collection[id][prop] = value;
    }
  
  if(prop === "artist" && value === "")
    {
      delete collection[id][prop];
    }
  
  return collection;
}

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.