I'm new to JavaScript, and I can never find an explanation to this in the tutorials I have gone through.
This example function calculates the length of user names.
My question is: How does "name" work in the function? It seems to be completely arbitrary what I call it, and how exactly does it work? In all explanations of functions I've gone through, the function parameter is used when the function is called with an argument, but there is nothing like that here.
It seems to me like "name.length" works like "users.length", but I don't understand why it's written like this.
const users = ['Nathan', 'John', 'William'];
const nameLengths = users.map(function(name) {
return name.length;
});
console.log(nameLengths);