Last active
January 10, 2017 08:14
-
-
Save mijimoco/9304f92d23ec24dc2c94258a827bcc48 to your computer and use it in GitHub Desktop.
Check for Palindromes Challenge
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
// This is the function we wrote in another challenge | |
function reverseString(str) { | |
var revStr = str.split('').reverse().join(''); | |
return revStr ; | |
} | |
// This one is the new function | |
function palindrome(str) { | |
// Good luck! | |
var newStr = str.replace(/\W/g, '').replace(/-/g, '').replace(/_/g, '').toLowerCase(); | |
if(newStr === reverseString(newStr)) { | |
console.log(newStr + ' true'); | |
return true; | |
} else console.log(newStr + ' false'); | |
return false; | |
//console.log(newStr); | |
} | |
palindrome("_eye"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment