Skip to content

Instantly share code, notes, and snippets.

@dmitry-korolev
Last active March 19, 2016 16:30
Show Gist options
  • Save dmitry-korolev/1a6d8ed5d150f51b054a to your computer and use it in GitHub Desktop.
Save dmitry-korolev/1a6d8ed5d150f51b054a to your computer and use it in GitHub Desktop.
function reverseString(string) {
var arr = new Array(string.length),
middle = Math.ceil(string.length / 2);
for (var x = 0, y = string.length - 1; x <= middle; x++, y--) {
arr[x] = string[y];
arr[y] = string[x];
}
return arr.join('');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment