Palindrome number

    0

    0

    pavan koka

    The isPalindrome function takes a string as an input and checks if the string is a palindrome. It splits the string into an array of characters and checks to see if the last character in the array is equal to the first character in the array. If the strings are not equal, the function returns false.

    var isPalindrome = function(x) {
      let isPalindrome = true;
      const arr = x.toString().split('');
      const length = arr.length;
      arr.forEach((el, index) => {
        if(el !== arr[length - 1 - index]) {
          isPalindrome = false;
        }
      })
      return isPalindrome
    };
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.