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

201
Views
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
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!