Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

206
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda