Skip to content

Instantly share code, notes, and snippets.

@basekays
Created June 19, 2018 18:13
Show Gist options
  • Select an option

  • Save basekays/8b7f184f07f8650c3cccdd3c4b08cd49 to your computer and use it in GitHub Desktop.

Select an option

Save basekays/8b7f184f07f8650c3cccdd3c4b08cd49 to your computer and use it in GitHub Desktop.
//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