Problem with "Basic JavaScript: Record Collection" - function psuh() undefined

Hi, I have a little problem; the console say to me that the function .push() doesn’t exist…

Thank you for your help!!!

Thank you for your answer! I clicked the Ask for Help button of this challenge… But I didn’t have a topic like you said haha sorry!

And here is my code :slight_smile:

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

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");

In the above code segment, if prop is “tracks” and value is not an empty string, then you check if the object has a prop property. If it does not exist, you assign value to it. Then in the last line, you push value to that same property. So, let’s say the first if statement condition is met and the inner if statement condition is met. Because there happens to be no “tracks” property yet. your code is going to assign a string to a “tracks” property and then the last line will attempt to push that same value to the “tracks” property. To use push, the value of “tracks” must be an array and not a string, which is why you get an error on one of the test cases. You need to adjust your inner if statement code block to assign a different value. What value should you be assign it, so the push line works accordingly?