Last active
July 10, 2018 10:00
-
-
Save Ginden/bf628e88be0886ac8340bdecf16e98f3 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.replace = function replace(map) { | |
const newArray = []; | |
for(const [index, value] of this.entries()) { | |
if(map.has(value)) { | |
newArray[index] = map.get(value); | |
} else { | |
newArray[index] = value; | |
} | |
} | |
return newArray; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment