Basic JavaScript: Record Collection(18 March 2020)

Dear Campers,

I could use a bit of feedback on getting started on this assignment. Here is the code:

// 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: [
      "1999",
      "Little Red Corvette"
    ]
  },
  1245: {
    artist: "Robert Palmer",
    tracks: [ ]
  },
  5439: {
    album: "ABBA Gold"
  }
};

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

console.log(collection)
  return collection;
}

updateRecords(5439, "artist", "ABBA");

I’m not sure if I’m starting my ā€˜else if’ statement correctly. The instructions says:

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

I followed accordingly and coded thus.

I appreciate any constructive feedback. Thanks , Campers. Please feel free to ask me anything regarding my code so far.

It’s checking if the property ā€œtracksā€ is not empty. Is that right?

(1) The ID number
(2) Album
(3) Artist
(4) and Tracks?

if updateRecords(47384384, "unnamed", "") was a new update, and the collection had a "unnamed" : ["random name"]; then when updateRecords runs, should return a new unnamed : "";

if (updateRecords[id] == ā€œtracksā€ && updateRecords[id] != ā€œā€) {
updateRecords[id].push(value)
}

Thanks for the input. I’m not quite sure what I’m missing. Does the parameter ID access the 4 property names? In my code above, I’m checking if each ID has the object, ā€œtracksā€ and is not an empty array. Does my push method belong in this if statement?