Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Function Call] Many solutions possible, but which one is correct? #182

Open
alejandroiglesias opened this issue Jun 15, 2017 · 0 comments

Comments

@alejandroiglesias
Copy link

For the Function Call exercise, there are many possible solutions, but I would like to know which ones have fewer drawbacks.

Official solution:

module.exports = Function.call.bind(Array.prototype.slice)

My solution 1:

module.exports = (arr, start, end) => Function.prototype.call.call(Array.prototype.slice, arr, start, end)

My solution 2:

module.exports = (arr, start, end) => Array.prototype.slice.call(arr, start, end)

All three solutions work. Of course the first is the most beautiful and easier to read of the three, but I wonder if other than that there can be technical drawbacks. Also, I think this exercise could be presented earlier in the course since it's not as difficult as the previous one.
Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant