Skip to content

Instantly share code, notes, and snippets.

  • Save anonymous/9caabe3c25987836e712 to your computer and use it in GitHub Desktop.
Save anonymous/9caabe3c25987836e712 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/twhite96 's solution for Bonfire: Reverse a String
// Bonfire: Reverse a String
// Author: @twhite96
// Challenge: http://www.freecodecamp.com/challenges/bonfire-reverse-a-string?solution=function%20reverseString(str)%20%7B%0A%20%20str%20%3D%20str.split(%27%27)%3B%0A%20%20str%20%3D%20str.reverse()%3B%0A%20%20str%20%3D%20str.join(%27%27)%3B%0A%20%20return%20str%3B%0A%7D%0A%0A%0A%0A%0A%0AreverseString(%22hello%22)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function reverseString(str) {
str = str.split('');
str = str.reverse();
str = str.join('');
return str;
}
reverseString("hello");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment