Nothing here yet.
Nothing here yet.
No blogs yet.
The forEach() method needs two arguments. First is the callback function and the second is the element which the this keyword can refer to the callback function. In the totalArray.forEach(adder()); , you are executing the adder function. Since adder is not returning anything from its body, you are getting undefined . As a result, your code is effectively calling the forEach() with undefined as the argument. For your code to run correctly, just omit the parenthesis while calling the function.