Created
June 19, 2018 18:13
-
-
Save basekays/8b7f184f07f8650c3cccdd3c4b08cd49 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| //input = string | |
| //output = string (can be modified string or new string) | |
| //test case | |
| //'hello' | |
| // -> 'olleh' | |
| function reverseString1(string) { | |
| var resultString = ''; | |
| for (var i = string.length-1; i >= 0; i--) { | |
| resultString = resultString.concat(string[i]); | |
| } | |
| return resultString; | |
| } | |
| function reverseString2(string) { | |
| return string.split('').reverse().join(''); | |
| } | |
| reverseString2('hello'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment