Skip to content

Instantly share code, notes, and snippets.

@mmloveaa
Last active April 4, 2016 17:41
Show Gist options
  • Select an option

  • Save mmloveaa/572320e1812adc7abca3931a039b8bc2 to your computer and use it in GitHub Desktop.

Select an option

Save mmloveaa/572320e1812adc7abca3931a039b8bc2 to your computer and use it in GitHub Desktop.
4-3 Regex - palindrome - Freecodecamp Q3
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