Skip to content

Instantly share code, notes, and snippets.

@Underdoge
Created March 6, 2017 03:01
Show Gist options
  • Save Underdoge/49808472d52786a02b1c844c55d0b93e to your computer and use it in GitHub Desktop.
Save Underdoge/49808472d52786a02b1c844c55d0b93e to your computer and use it in GitHub Desktop.
arrayReplace
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