Most developers especially those who are more into functional programming may find this to be clean, concise and performant at its best
I'm curious to know how many advocates of FP would write an add function in that way; where you use a callback to act on the result. You'd normally just return the result directly and avoid things that might cause unexpected side-effects (such as callback functions).
Also the uncondensed version is subject to the same bug:
numbers.forEach(function(nums, callback) {
The problem you demonstrate is that you need to be familiar with the argument signature passed from Array iteration functions. It's true that passing a function name means you may be less likely to spot the issue; but in my experience it's also rare to not write the function inline anyway.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In section 1 you say:
I'm curious to know how many advocates of FP would write an
add
function in that way; where you use a callback to act on the result. You'd normally just return the result directly and avoid things that might cause unexpected side-effects (such as callback functions).Also the uncondensed version is subject to the same bug:
numbers.forEach(function(nums, callback) {
The problem you demonstrate is that you need to be familiar with the argument signature passed from Array iteration functions. It's true that passing a function name means you may be less likely to spot the issue; but in my experience it's also rare to not write the function inline anyway.