Can't understand the problem and what am I doing wrong?

Tell us what’s happening:
What am I doing wrong? I also couldn’t understand the question very well.
Your code so far


// Setup
var collection = {
2548: {
  albumTitle: 'Slippery When Wet',
  artist: 'Bon Jovi',
  tracks: ['Let It Rock', 'You Give Love a Bad Name']
},
2468: {
  albumTitle: '1999',
  artist: 'Prince',
  tracks: ['1999', 'Little Red Corvette']
},
1245: {
  artist: 'Robert Palmer',
  tracks: []
},
5439: {
  albumTitle: 'ABBA Gold'
}
};

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

updateRecords(collection, 5439, 'artist', 'ABBA');

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36.

Challenge: Record Collection

Link to the challenge:

you can’t use dot notation to access object properties with variables, dot notation will try to access the variable using that literal name. You need to use bracket notation to access object properties with variables.

tell us what was unclear, we can explain it in a different way (as many different ways as you need)

Thank you. I didn’t know that about dot notation. After changing the dot notation to bracket, it satisfies all conditions but two.

After updateRecords(collection, 5439, "tracks", "Take a Chance on Me"), tracks should have Take a Chance on Me as the last element.
After updateRecords(collection, 2468, "tracks", "Free"), tracks should have 1999 as the first element.
// tests completed

I also have doubt on the second if statement. I’m assuming object[id].hasOwnProperty("tracks") will return false, but what if it doesn’t? Is there a better way to do this?

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

I also have doubt on the second if statement. I’m assuming object[id].hasOwnProperty("tracks") will return false, but what if it doesn’t? Is there a better way to do this?

I just checked the answers in the hint thread. And damn, this was solved with this single “!” before object[id].hasOwnProperty("tracks"). I understand it is clearing the doubt that I had (declaring specifically what to do when it DOES NOT return true). But we didn’t learn about using this in the curriculum…