I’ve edited your post for readability. When you enter a code block into the forum, remember to precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (`</>`

) will also add backticks around text.

If you put a console.log(n); on the line after the following:

```
n= a[0].indexOf(a[1][0]);
```

then you will see n is always 0. It is 0, because since a[0] is “hello” and a[1][0] is “h”, you are finding the index of “hello” which is “h” (which is 0) and then assigning it to n. Your for loop is doing the same thing 3 times. Instead of looking only at the 0 index of a[1], you should be looking at the ith index of a[1]. See if you can change a[1][0] to reflect the ith index instead of the 0 index of a[1].