How to modify this to arrow function

How to modify this to arrow function
0

#1

image

and
what is “Maximum call stack size exceeded”
why does it happen.

thank you for the answer.


#2

Because you have set it up so that add calls itself indefinitely. What is the url of this challenge?


#3

ES6: Write Higher Order Arrow Functions: https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/write-higher-order-arrow-functions
ES6: Use the Rest Operator with Function Parameters: https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-the-rest-operator-with-function-parameters

I consider that what it should be if combine these (func in func and (…args)) together in one line.
image


#4

I do not think that is possible, because you need to be able to name the function which is returned by the IIFE (Immediately Invoked Function Expression) and it can be done like:

return function add(...args) {
 // code goes here
}

OR you would need to define it first with const and then return it like:

const add = (() => {
  const add = (...args) => args.reduce((a, b) => a + b, 0);
  return add; 
})();

I just can not think of a way you can do it in one line, nor would I recommend it even if you could, because it is very unreadable like that.