Basic JavaScript - Record Collection

Tell us what’s happening:

Describe your issue in detail here.
I’m having trouble figuring out where the solution comes from. Where is the parameter “records” coming from, exactly? I get that it’s supposed to be in the function updateRecords, but how does the function connect it to the nested objects inside the object recordCollection? Nothing in the object itself calls itself a “record,” so why does the “records” parameter in the function connect to the nested objects inside recordCollection?

Your code so far

 // 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 (value==="") {
    delete record[id][prop];
    
  }



  return records;
}

updateRecords(recordCollection, 5439, 'artist', 'ABBA');

Your browser information:

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

Challenge Information:

Basic JavaScript - Record Collection

The function call determines the values used for the function parameters

There is no record, only records

I guess I was confused because in a previous lesson “Accessing Nested Objects,” it shows commands that link directly to the names of the object properties, like ourStorage.cabinet[“top drawer”].folder2, so I thought that I was trying to figure out why it wasn’t working the same here.

Which part isn’t working here? You can use bracket notation to access parts of the records object.

I’m just saying I was confused where the name of the object came from. I’m not saying the code doesn’t work, I just wanted clarification on the meaning behind it.

The name of which object?

These?

Yeah, basically. Why does records connect to the nested objects in recordCollection? The function updateRecords doesn’t mention recordCollection, so why does the first item in the list (records) connect to the first nested object in recordCollection? I just want to gain some understanding. Am I meant to infer that recordCollection would have been previously defined with those parameter names in a piece of code that isn’t shown in the lesson?

This is where all the sample function calls you’re given come in. They show you what sorts of function arguments will be used

This is more clear, thank you. I missed the line where recordCollection is used to call back.

1 Like