Basic JavaScript: Record Collection test issue

I’ve been stuck on the Record Collection JS task for a while now but as far as I can tell everything is working is as it should, only it’s still failing 3 of the tests.

For example ‘Take a Chance on Me’ should be the final ABBA track (it is when printed to console) but I’m still failing. Any ideas why?

Your code so far

// 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 object[id][prop]
else if (prop != 'tracks' && value != '') 
object[id][prop] = value;
 else if (prop === 'tracks' && object[id][prop] === [undefined]) 
object[id][prop] = [];
else if (prop === 'tracks' && value != '') {
object[id][prop] = value;
return object;

updateRecords(collection, 5439, 'artist', 'ABBA')
updateRecords(collection, 5439, 'tracks', 'Take a Chance on Me');
updateRecords(collection, 2548, "artist", "");
updateRecords(collection, 1245, "tracks", "Addicted to Love");
updateRecords(collection, 2468, "tracks", "Free");
updateRecords(collection, 2548, "tracks", "");
updateRecords(collection, 1245, "albumTitle", "Riptide");
console.log(updateRecords(collection, 1245, "tracks", "Addicted to Love"))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36.

Challenge: Record Collection

Link to the challenge:

Hello there,

Notice how all of the tests you are failing have to do with the tracks property when they are given a value.

Work from there.

1 Like

Thank you for the hint, I got there in the end with a ton of messing around. Was quite a hurdle for me