Skip to content

Instantly share code, notes, and snippets.

@GirlBossRush
Created February 5, 2019 19:20
Show Gist options
  • Save GirlBossRush/5e0ebe86333b9699a5cee2129bca5dc9 to your computer and use it in GitHub Desktop.
Save GirlBossRush/5e0ebe86333b9699a5cee2129bca5dc9 to your computer and use it in GitHub Desktop.
function swapEntries (array, index, targetIndex) {
const slice = array.slice()
slice.splice(targetIndex, 1, array[index])
slice.splice(index, 1, array[targetIndex])
return slice
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment