Last active
April 4, 2016 17:41
-
-
Save mmloveaa/572320e1812adc7abca3931a039b8bc2 to your computer and use it in GitHub Desktop.
4-3 Regex - palindrome - Freecodecamp Q3
This file contains hidden or 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
| function palindrome(str) { | |
| str= str.toLowerCase().replace(/[^a-z0-9]/g,'') | |
| //console.log("before strR: ", str) | |
| var strR = str.split('').reverse().join('') | |
| //console.log(strR) | |
| return strR === str | |
| } | |
| palindrome("0_0 (: /-\ :) 0-0"); | |
| //str = str.split('').filter(function(e){ | |
| // if(e===',' || e==='.' || e===' '){ | |
| // return false; | |
| // } else { | |
| // return true; | |
| // } | |
| //}).join('').toLowerCase() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment