Frontend101 logoFrontend101
← Problems
#17EasyJavaScript functions

17. Array.prototype.myMap

JavaScript

Implement Array.prototype.myMap(callbackFn, thisArg) to mirror native Array.prototype.map.

Example 1:
[1, 2, 3].myMap((x) => x * 2); // [2, 4, 6]
solution.js
Maps elements with index and array args
expect([1, 2, 3].myMap((x, i) => x + i)).toEqual([1, 3, 5])