Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check for palindromes

function palindrome(str) {
  var re = /[W_]/g;// representing Non-alphanumetic characters
  var lowRegStr = str.toLowerCase().replace(re, '');
  var reverseStr = lowRegStr.split('').reverse().join(''); 
  return reverseStr === lowRegStr;
}
palindrome("A man, a plan, a canal. Panama");
Source by www.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #check #palindromes
ADD COMMENT
Topic
Name
2+4 =