Created
March 6, 2017 03:01
-
-
Save Underdoge/49808472d52786a02b1c844c55d0b93e to your computer and use it in GitHub Desktop.
arrayReplace
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
function arrayReplace(inputArray, elemToReplace, substitutionElem) { | |
return inputArray.map((curr)=>{ | |
if(curr==elemToReplace) | |
return substitutionElem; | |
else | |
return curr; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment