We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents b5a58b4 + c5b7a22 commit 48a92a7Copy full SHA for 48a92a7
implementations/map.js
@@ -0,0 +1,18 @@
1
+/**
2
+ *
3
+ The map() method creates a new array with the results of calling a provided function on every element in the calling array
4
+
5
+ Callback is invoked with three arguments:
6
+ - the value of the element
7
+ - the index of the element
8
+ - the Array object being traversed
9
+*/
10
11
+Array.prototype.myMap = function(callback, thisArg) {
12
+ var mapArray = [];
13
+ for (let i = 0; i < this.length; i++) {
14
+ mapArray.push(callback.call(thisArg, this[i], i, this));
15
+ }
16
+ return mapArray;
17
+};
18
0 commit comments