Implement map
Implement map
Writing a small version of map makes the callback contract visible. The helper must call the callback once for each item, collect each returned value, and keep the output order aligned with the input order.
This is not about replacing the built-in method in real code. It is about understanding what the built-in method guarantees so you can reason about callback bugs later.
Your task: Complete customMap so it returns a new array of callback results. Pass the item, index, and original array to the callback. Do not use the built-in .map() method inside your implementation.
Free with a JS Exercises account
Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.
By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.
Implement map
Writing a small version of map makes the callback contract visible. The helper must call the callback once for each item, collect each returned value, and keep the output order aligned with the input order.
This is not about replacing the built-in method in real code. It is about understanding what the built-in method guarantees so you can reason about callback bugs later.
Your task: Complete customMap so it returns a new array of callback results. Pass the item, index, and original array to the callback. Do not use the built-in .map() method inside your implementation.