Skip to content

Instantly share code, notes, and snippets.

@farhanf
Created April 11, 2019 03:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save farhanf/1aba3c846dfb67c7fb29e1af1651aad1 to your computer and use it in GitHub Desktop.
Save farhanf/1aba3c846dfb67c7fb29e1af1651aad1 to your computer and use it in GitHub Desktop.

I am Swift developer and don't know JavaScript. But I attempted to answer this question.

I think the bug is in the definition of the lambda function. It uses x + i for every function that it stores. This will mean that i is a constant value for each function and will return the same result regardless of its position in the function array that is created.

I think the authors intention was to have the function return a result thats dynamic to what position is in the array of functions that is created. I am not sure how to fix this error in JS.

If this is not satisfactory I would request a function in swift or objective-c you would like me to debug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment