Build a Record Collection - Build a Record Collection

Tell us what’s happening:

I am missing test 6 and I believe the thing is that the value isn’t adding up to the last place of the array, which is odd because i have tried the algorithm separately and it works.

Your code so far

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'
  }
};



const updateRecords = (records, id, prop, value) => {
  const copyRecords = records;
  if(value === ''){
    delete copyRecords[id][prop]
    return copyRecords;
  } else if(prop !== 'tracks' && value !== ''){
    copyRecords[id][prop] = value;
    return copyRecords;
  } else if((prop === 'tracks' && value !== '') && ('tracks' in copyRecords !== true)){
    copyRecords[id][prop] = [];
    copyRecords[id][prop].push(value);
    return copyRecords;
  } else if(prop === 'tracks' && value !== ''){
    copyRecords[id][prop].push(value);
    return copyRecords;
  }
} 


Your browser information:

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

Challenge Information:

Build a Record Collection - Build a Record Collection
https://www.freecodecamp.org/learn/full-stack-developer/lab-record-collection/build-a-record-collection

if you add the following lines at the bottom of your js file, you can see the issue

updateRecords(recordCollection, 2468, "tracks", "Free")

console.log(recordCollection['2468'])

The console will print
{ albumTitle: '1999', artist: 'Prince', tracks: [ 'Free' ] }

(so you are erasing the other tracks instead of just adding Free)

Note - this line does not make a copy