Polyfill for Array.map()

Problem Statement

You are tasked with implementing a polyfill for the Array.map() method in JavaScript. The goal is to replicate the functionality of the native Array.map() method, which creates a new array by applying a provided function to each element of the array.

Write a function named map that takes a callback function as its argument and returns a new array with the results of applying the callback function to each element of the original array.


Your polyfill should support the following:

  1. Accept an optional second argument, which will be used as the value of this when executing the callback function.
  2. Handle the three parameters that the callback function receives: currentValue, index, and the array itself.

index.js
partial.test.js
complete.test.js
Editor Loading