Build a Record Collection - Build a Record Collection

Tell us what’s happening:

I’ve been stuck on this exercise for a couple weeks. I’ve used MDN and Google to try and solve all of the stories. I’m getting there, but I need help on a couple of tests.

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'
  }
};
function updateRecords(records, id, prop, value) {
  if (value === "") {
    // rule #2, delete property if value is empty
    delete records[id][prop];
  } else if (prop !== "tracks" && value !== "") {
    // rule #3, assign value
    records[id][prop] = records[id][prop].value;
  } else {
    records[id][prop] = records[id][prop] || []; // rule #4, create an array if missing
   records[id][prop].push([value]);        // rule #5, add value to array
  }
   return records; //rule #1, always return records object
}

Your browser information:

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

Challenge Information:

Build a Record Collection - Build a Record Collection

I think this line is a problem. What’s going on here?

I’m trying to assign value to the prop if it’s not tracks and not an empty string.

But what exactly are you assigning (what is on the right hand side)?

From what I am seeing, I think that if the property is anything other than tracks, and the value is not an empty string, I want that non-empty string to be the value for the property.

But what is on the right hand side of the =?

The value to assign as the prop

Hmm that’s not quite what it looks like to me. This looks like the value property of the existing quantity records[id][prop] instead of the new value that you want to assign.

I see. That makes sense. I’ll work on that now to have the assignment select the new value. Thank you very much.

1 Like