Heres a quick example of a selector. If you are making a selector like this, it is important that you use a function to make it easy for you as a programmer to do the loop. But if you are doing something else, like making a bunch of selectors like this, then you can do this all in one line.
If you ever want to do something like this in a loop, use a function with more than one parameter to tell it how to go about it. Its function name is just a number. The number tells it what to do, and the other parameters tell it what to do with the current selection of elements.
It’s not that I like to do these things in a loop, it’s just that I love it. If you’re going to do something like this in a loop, you need a more elegant way to do it in a more efficient way.