Record Collection: How are parameters being passed?

Hey everybody,

I’m having trouble understanding this problem. I don’t understand how the updateRecord parameters are being passed in. In our setup above there are no variables in our object equated to records, prop, id, or value.

Am I missing something here? I feel like a skipped a lesson or something, how are these parameters being passed in?

  **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 (prop !== track && value !== ""){
  records[id][prop]
}
return records;
}

updateRecords(recordCollection, 5439, 'artist', 'ABBA');
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36

Challenge: Record Collection

Link to the challenge:

prop will be a string like ‘artist’ or ‘tracks’.

id will be a number like 2548.

records will be a complex object like recordCollection.

Are these variables just being declared and tested when you run the code on FCC? Or does the program understand somehow that prop will be the strings and specifically it will be ‘artist’ or ‘tracks’, etc.

If you have a function definition

function myFunction(myArg) {
  //...
}

and you call the function like so

myFunction(5);

you’re saying 'use myArg = 5'.

Right, but can you point to me where that is happening in the record collection problem? Are the parameters being defined after the fact when you run the code? I think that’s where i’m confused

The parameters are defined every time the function is called. The tests call your function many times and make sure it returns the right output for specific inputs.

The function calls are listed below the challenge description.

1 Like

Nope. Take this for example:

function myNameAndAge(name, age)

The function now assumes you’re passing in those specific arguments.

You could pass myNameAndAge(18, John) But that wouldn’t make sense. So you pass in myNameAndAge(John, 18), instead.

The order of the parameter should be accurate to the order of the arguments passed.

1 Like

Okay I see, I totally forgot about that, thanks for clarifying I appreciate it!

1 Like