Basic JavaScript: Record Collection test fail

I am working my way through the Basic JavaScript Curriculum, but I seem to have ran into a problem with the Record Collection section. I followed the hint guide (hence all the comments in the code, intend to save it for future reference and for personal practice and work), but for some reason it keeps failing one of the tests. When I run the tests, I get the following error: updateRecords(…)[5439].tracks.pop is not a function

I have looked over my code, but I can not find anything out of place that might be tripping this test up. I have also used console.dir(collection) to print the object to the console, and when I enter the information for the test that keeps failing, the changes it is supposed to be making are being made.

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": [ 
        "Little Red Corvette" 
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    "5439": {
      "album": "ABBA Gold"
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  if (prop === "tracks" && value !== "") { //checks to see if the prop equals tracks and if the tracks section is empty

    if(collection[id][prop]) { //checks to see if the prop exists
      collection[id][prop].push(value); //inserts the value into the end of the tracks array if the tracks array exists and if the value is not empty.
      collection[id][prop] = value; //if prop isn't tracks and value isn't empty, this updates or sets the value for that property
  else if (value !== "") { //checks to see if value is blank or not.
    collection[id][prop] = value; //If the above statement is true, it either creates a new key and value, or an existing key is updated with the new value.
  else {
    delete collection[id][prop]; //if there are no values in the given prop property, this deletes the property from the album.
  return collection; //returns the whole collection

// Alter values below to test your code
updateRecords(5439, "tracks", "Take a Chance on Me");

And a link to the lesson:

Pretty close!

Remember that tracks is an array. You are simply assigning it to a string instead of a string inside an array.

1 Like

Thank you! Your comment helped me focus on the problem area and identify the issue and solution.

Now to practice this and other things for a bit before continuing.