Skip to content

Instantly share code, notes, and snippets.

@mtroiani
Created December 11, 2015 20:42
Show Gist options
  • Save mtroiani/81ad68a1f19027086ed2 to your computer and use it in GitHub Desktop.
Save mtroiani/81ad68a1f19027086ed2 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/mtroiani 's solution for Bonfire: Check for Palindromes
// Bonfire: Check for Palindromes
// Author: @mtroiani
// Challenge: http://www.freecodecamp.com/challenges/bonfire-check-for-palindromes
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function palindrome(str) {
str = str.toLowerCase().replace(/[^\w]|_/g, "");
var reversedStr = str.split("").reverse().join("");
if (str === reversedStr)
return true;
else return false;
}
palindrome("A man, a plan, a canal. Panama");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment