Last active
March 19, 2016 16:30
-
-
Save dmitry-korolev/1a6d8ed5d150f51b054a 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 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