Record Collection Test Help

Tell us what’s happening:
All the tests are passing except for the ones that check the tracks properties like

After updateRecords(5439, "tracks", "Take a Chance on Me") , tracks should have "Take a Chance on Me" as the last element.

I’ve tried running the function and it seems to be working just fine. Can anyone tell me what’s wrong with this code?

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: [
    "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[id].hasOwnProperty(prop) && value == ""){
  return delete collection[id][prop];
}
else if (collection[id].hasOwnProperty(prop) && value != ""){
  if (prop == "tracks") {
    return collection[id]["tracks"].push(value);
  }
  else {
    return collection[id][prop] = value;
  }
}
else if (prop == "tracks"){
 collection[id]["tracks"] = [];
 return collection[id]["tracks"].push(value);
}
else if (prop != "tracks"){
  collection[id][prop]= value;
}

return collection;
}

updateRecords(5439, "tracks", "Take a Chance on Me");
updateRecords(1245, "tracks", "Addicted to Love");
console.log(collection);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:79.0) Gecko/20100101 Firefox/79.0.

Challenge: Record Collection

Link to the challenge:

Hi!

Remove all keywords ‘return’ in your code (except ‘return collection’), because you have to set or update the values and NOT to RETURN them!

I hope it helps!

This helped, thank you very much!