Created
May 28, 2019 14:04
-
-
Save valentingavela/df258286a8603d59918502ea7eb25bdc to your computer and use it in GitHub Desktop.
This file contains 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 swap(arr, index1, index2) { | |
if (index1 === index2) throw Error; | |
[arr[index1], arr[index2]] = [arr[index2], arr[index1]]; | |
return arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment