0

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**

Jose Lora
  • 1,430
  • 3
  • 10
  • 17
  • Does this answer your question? [All falsey values in JavaScript](https://stackoverflow.com/questions/19839952/all-falsey-values-in-javascript) – Randy Casburn Nov 17 '21 at 18:53

0 Answers0