These are chat archives for camperbot/bonfire-check-for-palindromes

Sep 2015
Joseph odhiambo
Sep 10 2015 10:03 UTC
Sep 10 2015 10:03 UTC

hint [8/8]


function palindrome(str) {
  str = str.toLowerCase().replace(/[\W_]/g, '');
  for(var i = 0, len = str.length - 1; i < len/2; i++) {
    if(str[i] !== str[len-i]) {
      return false;
  return true;

Code Explanation:

We use regular expressions to replace any uppercase letter into a lowercase. Then we check if the string is the same as the reversed string using split() to split the original string by characters, then reverse and then join it back together.


If you found this page useful, you can give thanks by copying and pasting this on the main chat: Thanks @Rafase282 @abhisekp

type hint for next hint :pencil: [Contribute at the FCC Wiki]