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

Remove unnecessary arguments #158

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Remove unnecessary arguments #158

wants to merge 1 commit into from

Conversation

gs20060101
Copy link

The function "fn" is a user-supplied function that would not take "index" and "arr" arguments.

The function "fn" is a user-supplied function that would not take "index" and "arr" arguments.
@aonghusonia
Copy link

aonghusonia commented May 9, 2018

the callback function supplied to Array.prototype.map() takes three arguments:

currentValue: The current element being processed in the array.
index (Optional): The index of the current element being processed in the array.
array (Optional): The array map was called upon.

the tests pass even if you leave the second two out (see below) but I think the official solution is more complete with them

module.exports = function map(arr, fn) {
  return arr.reduce(function(acc, item, index) {
    acc[index] = (fn(item))
    return acc
  }, [])
} 

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

Successfully merging this pull request may close these issues.

2 participants