Regarding the code in the challenge below, I understand how to use an arrow function, but some of the details are confusing me. If “users” is a variable that we created, why does the function also use the singular “user” and how is it distinguished from its plural form?
It’s not distinguished in a way you think. user => user.name might be here as well whatever => whatever.name. In this example, user is just used as a name for the one element from the users array.
Yes! It can be anything but convention-wise, it’s good if the placeholder is descriptive of what each element is (in case you come back to your code 3 months later, or even a week later , or someone else takes it over). In this case, the pluralized form users can be confusing because you’re working on, in fact, just one user at a time
When I’m going for tiny and terse, I often just use the first letter, e.g. users.map(u => u.foo()). What it’s operating on is still pretty obvious. In a classic loop body where things are more separated, I tend to go for the full singular word.