Skip to content

Instantly share code, notes, and snippets.

@TastyToast
Created March 15, 2013 03:50
Show Gist options
  • Save TastyToast/5167359 to your computer and use it in GitHub Desktop.
Save TastyToast/5167359 to your computer and use it in GitHub Desktop.
Return Reversed Array (Swap method)
function temporarySwap(array)
{
var left = null;
var right = null;
var length = array.length;
for (left = 0, right = length - 1; left < right; left += 1, right -= 1)
{
var temporary = array[left];
array[left] = array[right];
array[right] = temporary;
}
return array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment