Record collection function

Please help, I almost got it but can’t figure out why ‘test 2’ wont pass.

// 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) {
   // Access target album in record collection
    const album = records[id];

    if(value == ''){
      delete album[prop];
    }
    
    else if(prop == 'tracks' && value !== ''){
      album.tracks.push(value);
    }else if(prop == 'tracks' && album.tracks == null) {
    album[prop] = value;
    }

    else if(prop !== 'tracks' && value !== ''){
      album[prop] = value;
    }
    return records;
}
updateRecords(recordCollection, 5439, 'artist', 'ABBA');

Please post a link to the challenge so we can read it and see what you mean.

1 Like

Can you explain what you think this part is doing?

1 Like

Thank you Both for responding so quickly. I figured it out after taking a nap lol :grinning:

Turns out I was not creating an empty array to be propagated by “value”. Just needed to sleep on it. Thank ya’ll so much, appreciate you.

1 Like

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