Basic JS Record Collection exercise - I don't understand the link between parameters and keys

Hi everyone, I had managed to solve most things on my own but that part stumps me and I’d really like to have a deeper understanding because I’m using fCC to review JS and practice. So after checking out other posts about this exercise I get the general gist of it and reading the solution does make sense, but I couldn’t independently arrive at it - this sounds like a bit of a dumb question but how exactly would the function “know” that the argument I’m passing is, for example, an id by just receiving a random number without there being an explicit connection made between these elements beforehand? The function has three parameters that are used to access different levels of the object(s) and somehow it works, but I don’t get how and it’s driving me crazy…

Edit: sorry, forgot to link the exercise, here it is —>

Well, if collection[1] is undefined then means that the object doesn’t have that key inside… everything breaks and the function should do nothing - or create it, depending on how things are handled. But the challenge supposes that the ids are in the object, so don’t worry about the chance that they are not there.

Anyway, it would be really great if you would pass the link to the challenge when you ask for help, and any code you have written so far if you need help with your code