Record Collection Questions

Below I just copy and pasted the code that we are to modify (without the solution as I don’t think it is relevant to my questions.)

What I am struggling with is how does JS “know” what the parameters represent? For example, the id parameter is going to return each individual record and it’s contents! How? How does it know what data to return? How does it know that the 4 digit code is the ID? I don’t see any code that defines ID or links it to their corresponding numbers.

The prop and value parameters make a bit more sense since they are named according to what they are ( a parameter named prop is literally a prop, a parameter named value is literally a value) but still, when was this defined in the code?

Are ID, prop and value some sort of universal designation? I don’t think so but maybe I’m wrong.

It’s these kind of questions that just freeze me up because I can’ t even assess what the problem is, let alone how to solve it.

Thanks to all in advance

// 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) {
return records;
}

updateRecords(recordCollection, 5439, ‘artist’, ‘ABBA’);

The function call supplies the values of the arguments

Thank you. I understand better now.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.