Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Austin Franks
    @AustinLF
    hint
    CamperBot
    @camperbot

    hint [3/9]

    Hint: 1

    You may use regular expressions (RegExp) to remove unwanted characters from the string.

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

    Austin Franks
    @AustinLF
    hint
    CamperBot
    @camperbot

    hint [4/9]

    Hint: 2

    You may use Array.prototype.split and Array.prototype.join methods or for loop.

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

    Austin Franks
    @AustinLF
    hint
    CamperBot
    @camperbot

    hint [5/9]

    Hint: 3

    You may lowercase the string using String.prototype.toLowerCase.

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

    Austin Franks
    @AustinLF
    hint
    CamperBot
    @camperbot

    hint [6/9]

    Spoiler Alert!

    687474703a2f2f7777772e796f75726472756d2e636f6d2f796f75726472756d2f696d616765732f323030372f31302f31302f7265645f7761726e696e675f7369676e5f322e676966.gif

    Solution ahead!

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

    Austin Franks
    @AustinLF
    hint
    CamperBot
    @camperbot

    hint [7/9]

    First

    function palindrome(str) {
      var normalizedStr = str.replace(/[\W_]/g, '').toLowerCase();
      var reverseStr = normalizedStr.split('').reverse().join('');
      return normalizedStr === reverseStr;
    }

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

    Austin Franks
    @AustinLF
    hint
    CamperBot
    @camperbot

    hint [8/9]

    Second

    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.

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

    Austin Franks
    @AustinLF
    hint
    CamperBot
    @camperbot

    hint [9/9]

    Recursive Solution

    function palindrome(str) {
    // make all letters lowercase and remove non-alphanumeric characters
      str = str.toLowerCase();
      str = str.replace(/[^a-z|1-9]/g, "");
    
      // if the length of the string is 0 then it is a palindrome
      if (str.length === 0){
        return true;
      }
      // if the first letter and the last letter of the string do not equal eachother then it is not a palindrome
      if (str[0] !== str[str.length-1]){
        return false;
      }
      //Else, run the function without the first and last characters.
      else{
        return palindrome(str.slice(1,str.length - 1));
      }
    }

    Credits:

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

    NOTE: Please add your username only if you have added any relevant main contents to the wiki page. (Please don't remove any existing usernames.)

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

    Stjepan Mazalovic
    @stjema
    hint
    CamperBot
    @camperbot
    These hints depend on people like you! Please add to this :point_right: Bonfire's Wiki Hints Page
    Alexa
    @zaOne101
    Thanks @Rafase282 @abhisekp @shadowfool
    CamperBot
    @camperbot
    zaone101 sends brownie points to @rafase282 and @abhisekp and @shadowfool :sparkles: :thumbsup: :sparkles:
    :star: 1254 | @abhisekp | http://www.freecodecamp.com/abhisekp
    :star: 344 | @shadowfool | http://www.freecodecamp.com/shadowfool
    :star: 735 | @rafase282 | http://www.freecodecamp.com/rafase282
    Alexa
    @zaOne101
    hint
    CamperBot
    @camperbot

    hint [1/9]

    ## :construction: After this are possible spoiler hints.

    Make sure you've tried to hard to solve it yourself before proceeding. :construction:

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

    Alexa
    @zaOne101
    hint
    CamperBot
    @camperbot

    hint [2/9]

    Explanation:

    You have to check if the string you get as an input is a palindrome and return true if it is, and false otherwise.

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

    Alexa
    @zaOne101
    hint
    CamperBot
    @camperbot

    hint [3/9]

    Hint: 1

    You may use regular expressions (RegExp) to remove unwanted characters from the string.

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

    danieljuiche
    @danieljuiche
    hint
    CamperBot
    @camperbot

    hint [4/9]

    Hint: 2

    You may use Array.prototype.split and Array.prototype.join methods or for loop.

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

    danieljuiche
    @danieljuiche
    hint 1
    CamperBot
    @camperbot

    hint [2/9]

    Explanation:

    You have to check if the string you get as an input is a palindrome and return true if it is, and false otherwise.

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

    danieljuiche
    @danieljuiche
    hint 1
    CamperBot
    @camperbot

    hint [2/9]

    Explanation:

    You have to check if the string you get as an input is a palindrome and return true if it is, and false otherwise.

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

    danieljuiche
    @danieljuiche
    hint 0
    CamperBot
    @camperbot

    hint [1/9]

    ## :construction: After this are possible spoiler hints.

    Make sure you've tried to hard to solve it yourself before proceeding. :construction:

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

    danieljuiche
    @danieljuiche
    hint 1
    CamperBot
    @camperbot

    hint [2/9]

    Explanation:

    You have to check if the string you get as an input is a palindrome and return true if it is, and false otherwise.

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

    danieljuiche
    @danieljuiche
    hin 2
    hint 2
    CamperBot
    @camperbot

    hint [3/9]

    Hint: 1

    You may use regular expressions (RegExp) to remove unwanted characters from the string.

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

    danieljuiche
    @danieljuiche
    hint 3
    CamperBot
    @camperbot

    hint [4/9]

    Hint: 2

    You may use Array.prototype.split and Array.prototype.join methods or for loop.

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

    danieljuiche
    @danieljuiche
    hint 4
    CamperBot
    @camperbot

    hint [5/9]

    Hint: 3

    You may lowercase the string using String.prototype.toLowerCase.

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

    danieljuiche
    @danieljuiche
    hint 5
    CamperBot
    @camperbot

    hint [6/9]

    Spoiler Alert!

    687474703a2f2f7777772e796f75726472756d2e636f6d2f796f75726472756d2f696d616765732f323030372f31302f31302f7265645f7761726e696e675f7369676e5f322e676966.gif

    Solution ahead!

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

    danieljuiche
    @danieljuiche
    hint
    CamperBot
    @camperbot

    hint [7/9]

    First

    function palindrome(str) {
      var normalizedStr = str.replace(/[\W_]/g, '').toLowerCase();
      var reverseStr = normalizedStr.split('').reverse().join('');
      return normalizedStr === reverseStr;
    }

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

    danieljuiche
    @danieljuiche
    hint
    CamperBot
    @camperbot

    hint [8/9]

    Second

    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.

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