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:
- String with character (It could be any letter including space) For example
'1'or'a'or' ' - 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**