Skip to content

Instantly share code, notes, and snippets.

@enieber
Created August 21, 2018 12:31
Show Gist options
  • Select an option

  • Save enieber/5055fbc2d080aeec86e993218bef5868 to your computer and use it in GitHub Desktop.

Select an option

Save enieber/5055fbc2d080aeec86e993218bef5868 to your computer and use it in GitHub Desktop.
const move = (arr, from, to) => {
const newArr = arr.map((x, i, t) => {
if(t[i] == from){
return to;
} else if(t[i] == to) {
return from;
} else {
return x;
}
});
return newArr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment