Record Collection challenge - need help

Yes, that is true coz all these conditions are mutually exclusive.

1 Like

Ok, so here is my current code. I am almost there. Now the only test I am not passing is shown below. But my console.log shows that the track is there even though the error says it isn’t. What gives?

// 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) {
  if (prop !== "tracks" && value !== "")
      records[id][prop] = value;
    } else if (prop === "tracks" && records[id].hasOwnProperty("tracks") === false)
        records[id].tracks = value;
      } else if (prop === "tracks" && records[id].hasOwnProperty("tracks") === true && value !== "")
        else if (value === "")
            delete records[id][prop];

  return records;

updateRecords(recordCollection, 5439, 'tracks', 'Take a Chance on Me');


You’re missing a small piece of the instructions. What will happen if you try to add another track?

1 Like

Oh. So that’s how you create a property as an array. Ok…I just put brackets around value and it passes now.

Btw, using console.log and playing with the parameters was very helpful to see what it was doing with each if statement.

Also, I haven’t touched this since a week ago. I came back to it today and did the solution from scratch with just that little bit tripping me up. I’m pleasantly surprised!

1 Like