Created
April 3, 2017 10:28
-
-
Save Obre/b0a8b35615402d6d6b43c21fd8ed9507 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 reverseStringBuiltIn(str) { | |
return str.split("").reverse().join(""); | |
} | |
console.log(reverseStringBuiltIn("himeinnameistundichbin")); | |
function reverStringForLoop(stri) { | |
var newString = ""; | |
for (i = stri.length-1; i>=0; i--) { | |
newString += stri[i]; | |
} | |
return newString; | |
} | |
console.log(reverStringForLoop("hallowiegehtesdir")); | |
function reverseStrRecursion(string) { | |
if (string === "") | |
return; | |
else | |
return reverseStrRecursion(string.substr(1)) + string.charAt(0); | |
} | |
console.log(reverseStrRecursion("hellothisisme")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment