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

160
Views
Comparar dos matrices si son iguales devuelve falso incluso si son iguales

Con el siguiente código estoy comprobando si str es un palíndromo. (Un palíndromo es una palabra u oración que se escribe de la misma manera hacia adelante y hacia atrás). Aunque son lo mismo, la función todavía me da un retorno falso... ¿Por qué es eso? Sé que podría unir los arreglos a cadenas individuales con .join('') pero aún me gustaría saber cuál es el problema con mi código y por qué no funciona

 function palindrome(str) { let newStr = str.toUpperCase().replace(/[^AZ\d]/g, '').split(''); let newStrRev = [...newStr].reverse(); //.reverse() is not destructive anymore console.log(typeof newStr, newStr); //OUTPUT: object [ 'R', 'A', 'C', 'E', 'C', 'A', 'R' ] console.log(typeof newStrRev, newStrRev); //OUTPUT: object [ 'R', 'A', 'C', 'E', 'C', 'A', 'R' ] if (newStr === newStrRev) { return true } else { return false } } console.log(palindrome("race car")); //OUTPUT: false
about 4 years ago · Santiago Trujillo
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!