Created
December 11, 2015 20:42
-
-
Save mtroiani/81ad68a1f19027086ed2 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/mtroiani 's solution for Bonfire: Check for Palindromes
This file contains 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
// 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