Skip to content

Instantly share code, notes, and snippets.

@marko-jankovic
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marko-jankovic/982a408612533cd3f6ca to your computer and use it in GitHub Desktop.
Save marko-jankovic/982a408612533cd3f6ca to your computer and use it in GitHub Desktop.
String reverse example
var text = "Gist is a simple way to share snippets and pastes with others.",
textLength = text.length,
lastItem = textLength - 1,
textToArray = text.split("");
for(var i=0; i<textLength/2; i++) {
textToArray[i] = textToArray.splice(lastItem-i, 1, textToArray[i])[0];
}
console.log(textToArray.join(""));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment