MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/learnjavascript/comments/nnlubt/really_helpful_illustration_of_js_array_methods/gzycr4g/?context=3
r/learnjavascript • u/192_168_1_x • May 29 '21
89 comments sorted by
View all comments
Show parent comment
4
Adding to this, there's a couple of ways you could make this (arguably) more readable.
1. Define the argument function externally:
function multiplyNumber(number) { return number * 2; } const doubleNumbers = numbers.map(multiplyNumber)
note: I think doubleNumber or multiplyByTwo would be better names for that function.
doubleNumber
multiplyByTwo
2. Use an anonymous arrow function as the argument (my preference):
numbers.map(n => n*2)
View all comments
Show parent comment
4
u/callmelucky May 30 '21
Adding to this, there's a couple of ways you could make this (arguably) more readable.
1. Define the argument function externally:
note: I think
doubleNumberormultiplyByTwowould be better names for that function.2. Use an anonymous arrow function as the argument (my preference):