Help me troubleshoot my Record Collection Solution

Here is the code solution:

// Setup
const recordCollection = {
  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(records, id, prop, value) {
   // var album = recordCollection[id]

  if (prop != "tracks" && value != "") {
    recordCollection[id][prop]= value;
  } else if (prop == "tracks" && !recordCollection[id].hasOwnProperty("tracks")) {
    var tracks = [];
  recordCollection[id][prop] =tracks;  
  } else if (prop == "tracks" && value != ""){
  } else  {
    delete recordCollection[id][prop];
return recordCollection;


updateRecords(recordCollection, 5439, 'ABBA GOLD', 'ABBA');

Here is the link:

Please be specific about what I need to address or re-write the code with a bit of explanation. Thanks

With how you have this function coded now it is not very reusable. It set up to only work if recordCollection is there. Try fixing the references to that object.

Please be specific about what parts don’t work and what you have tried to fix them.

You should not be using var at this point

The “var” declaration has been commented out. The second condition downward is not working. I have tried Youtube videos. Thanks.

Thanks. Can u show me how the references to that object should be?

Do you understand all the arguments being passed to the function and how to use them inside the function? There is an object being passed in the function call that you should be using.

I do not understand all the arguments and how to use them. Kindly explain.

Which arguments do you understand?

I understand the arguments: id, prop and value and i made use of them in the code but i do not understand record and its use in the code.

records is an object made up of a bunch of individual record objects. Currently, your code directly uses the recordCollection variable, but what if you had rockRecordCollection or popRecordCollection? The function is supposed to accept different sets of records as the `rrecords parameter

By the way, this is the var I was talking about

Ok. let me try the change. Thanks.

The first argument of the function is records (not the recordCollection, which is a record instance).

Also, I think “let” is advised within functions as against “var”.
For exactness, use === and !==


It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.


Thanks. The problem is Solved.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.