Record Collection ,i face these 2 eror

// Setup
var collection = {
  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(object,id, prop, value) {
     if (value === "") {
    delete collection[id][prop];
  } else if (prop === "tracks") {
    collection[id][prop] = collection[id][prop] || [];
    collection[id][prop].push(value);
  } else {
    collection[id][prop] = value;
  }
  
  return collection;
}
updateRecords(collection, 5439, "artist", "ABBA");

Error
1-After updateRecords(collection, 2548, "tracks", "") , tracks should not be set
2- After updateRecords(collection, 2548, "artist", "") , artist should not be set

Hello~!

The logic in your code is spot on - nice work!

The reason you are encountering these errors is you are hard-coding the collection object directly into your function. If you instead modify the value passed into the object parameter, your code will pass.

1 Like

Thank you @nhcarrigan