Created
March 17, 2017 08:53
-
-
Save kemalkanok/e23c0290ad919532ea8d289adbfca7ec to your computer and use it in GitHub Desktop.
general reverse method
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
<script> | |
function start() { | |
// var text = prompt("here a text"); | |
text="adanada"; | |
// text = text.split('').reverse().join(''); | |
// console.log(eval(text)); | |
text = join(reverse(split(text))); | |
console.log(text); | |
} | |
function split(keyword) { | |
result = []; | |
for (var i = 0; i < keyword.length; i++) { | |
result.push(keyword[i]); | |
} | |
return result; | |
} | |
function reverse(arr) { | |
result = []; | |
for (var i = arr.length - 1; i >= 0; i--) { | |
result.push(arr[i]); | |
} | |
return result; | |
} | |
function join(arr) { | |
result = ""; | |
for (var i = 0; i < arr.length; i++) { | |
result += arr[i]; | |
} | |
return result; | |
} | |
start(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment