You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was fascinated by the solution of reduce function. Can anyone tell me about your thoughts here? How you analysis this problem and tackle it step by step? Thank you!
The text was updated successfully, but these errors were encountered:
Recursion is another method to solve this problem.We can't use recursion in the "fn", because we can't override this function, but we can use recursion in our reduce function to execute the "fn" function many times, and make the inintial be the right answer.
@fkysly, that's a good solution and it's what i've done at first. But the index agrument in callback function becomes useless this way, because it's always equal to 0, so user can't get the index of the item in the array.
I was fascinated by the solution of reduce function. Can anyone tell me about your thoughts here? How you analysis this problem and tackle it step by step? Thank you!
The text was updated successfully, but these errors were encountered: