Skip to content

Instantly share code, notes, and snippets.

@GeekaholicLin
Created August 29, 2016 15:10
Show Gist options
  • Save GeekaholicLin/3e6b440c2ff75a9f36faf8001542a32e to your computer and use it in GitHub Desktop.
Save GeekaholicLin/3e6b440c2ff75a9f36faf8001542a32e to your computer and use it in GitHub Desktop.
Two simple method achieve reversing the string
function reverseString(str) {
 //method 1.
  str = str.split('').reverse().join('');
  
  //method 2
  /*var str2 = "";
  for(var i = str.length-1;i>=0;i--){
    str2+=str.charAt(i);
   }
  str = str2;*/
  return str;
 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment