Created
February 13, 2017 00:28
-
-
Save MarcusHurney/8837f155e6ac14416334195cefd55e9a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.createMap = Array.prototype.createMap || function(callback) { | |
var newArray = []; | |
for (var i = 0; i < this.length; i++) { | |
var result = callback(this[i], i); | |
newArray.push(result); | |
} | |
return newArray; | |
} | |
var start = [1, 2, 3]; | |
var transformedArray = start.createMap(function(value, index) { | |
return value + 1; | |
}); | |
console.log(transformedArray); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment