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

324
Views
Function in the another function: isPalindrome is not a function

I'm trying to write a function that takes another function and then executes it in reverse. And it don't work :( Mistake is: TypeError: isPalindrome is not a function. Where is a problem?

const isPalindrome = (text) => {
  let text1 = text.toLowerCase();
  let text2 = text1.split('').reverse().join('');
  return text1 === text2;
}

const isNotPalindrome = (isPalindrome) => {
  !isPalindrome();
};
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you really want to encapsulate it into a method you can do that:

const isPalindrome = (text) => {
  let text1 = text.toLowerCase();
  let text2 = text1.split('').reverse().join('');
  return text1 === text2;
}

const isNotPalindrome = (text) => !isPalindrome(text);

console.log(isPalindrome('test'));
console.log(isNotPalindrome('test'));

However, since it does not make really sense to create a method to just return the opposite you could simply do:

const isPalindrome = (text) => {
  let text1 = text.toLowerCase();
  let text2 = text1.split('').reverse().join('');
  return text1 === text2;
}

console.log(isPalindrome('test'));
console.log(!isPalindrome('test'));

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!