Q:

.style.color is working but still throws an error

I am trying to make HTML paragraph element appear by changing their color. The line where I style the specific elements (multiple elements, its inside a for loop) is throwing an error. It works fine but after that line I cant do anything since the error stops it.
This is the code (its stopped by the chrome tools). U can see that the element is defined, and if I hover over it displays the exact one I need.

The error message says the element is undefined but I am absolutely sure it is, I have no clue what to do.

const letterIndex = findIndexOfLetter(word, letter.innerHTML);
    for (w = 0; w <= letterIndex.length; w++) {
      var theLetter = wordLetters[letterIndex[w]]
      theLetter.style.color = "azure";
    }

A:

When iterating over an array (or an array-like collection, not important here) with the for loop, you go
for (let i = 0; i < collection.length; i++) { //...

and not
for (let i = 0; i <= collection.length; i++) { //...

With the <= stop condition, the last iteration is outside the array.

