Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
Palindrome string used by predefined function but unable to solve as it is showing only one error

// Unable to understand what is wrong in this code always showing string is not // palindrome

                 **Check this**    


        <script>

      var isPalindrome = function (str) {
        const st = str.split("").reverse().join();
        console.log(st);

        if (str == st) {
          console.log("It is a palindrome");
        } else {
          console.log("It is not a palindrome");
        }
      };
      let str = "abba";

      isPalindrome(str);

    </script>

               //I have tried a lot. unable to understand why stack overflow is taking to much time to upload only showing err //
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

const isPalindrome = (str) => {
  const str2 = str.split("").reverse().join("");

  if (str == str2) {
    console.log("It is a palindrome");
  } else {
    console.log("It is not a palindrome");
  }
};

isPalindrome('aabb');
isPalindrome('abba');

about 4 years ago · Juan Pablo Isaza Report

0

You can try this,

function palindrome(str) {
  let reversed = str.split('').reduce((acc, cur) => cur + acc, '');
  if (str === reversed) {
    return true;
  } else {
    return false;
  }
}
let str = "abba";
console.log(palindrome(str));
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!