How about splitting things up?
timesTwo = e => e * 2;
add = (a, b) => a + b;
const result = arr
.map(add) // add index
putting maps on separate lines helps people see it broken in to steps
adding in a comment on the "add" helps because most maps don't usually use index.
you could do .map(addIndex) but I don't like this as the original function can add any two things, not just index
or .map((a, i) => add(a, i)) but that creates another function
.map((a, i) => add(a, i))
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.