Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

211
Vistas
String with space taken from array isn't equal to another identical string taken from text by index

I have the text and I have a variable with the current index of the current letter in this text. I also have an array that contains arrays with two elements:

  1. String with character (It could be any letter including space) For example '1' or 'a' or ' '
  2. HTML Element.

It looks like this:

const arr = `[['1', document.querySelector('.k-one')], ['a', document.querySelector('.k-a')], [' ', document.querySelector('.k-space')], and so on...]`

Then I need to get a subarray with the first element equals to text[currentIndex] (sting which contains letter)

So I use arr.find(array => array[0] == text[currentIndex]) and everything goes OK until text[currentIndex] isn't ' '
In this case I get an error, because arr.find(array => array[0] == text[currentIndex]) returns undefined because array[0] == text[currentIndex] returns false

but when I log array[0] and text[currentIndex] both of them returns a string with space like this ' '

**I don't understand what happens and what goes wrong.

How can two identical strings return false when I compare them**

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda