6. Second loop should accept j = 0


This code is valid too:

for (var i = 0; i < text.length; ++i) {
    if (text[i] === 'K') {
        for (var j = 0; j < myName.length; ++j) {
            hits.push(text[i + j])    

Right now it's being rejected with the reason "Careful: your second 'for' loop should stop when it reaches its current point in the string + myName.length.", which is nonsense because it'll actually break the program.


How would it break the program? The point is to take their approach so you see what is trying to be done.


It will result in a JS equivalent of "index out of range" exception.


And how would this result? Every instruction they provide, if properly followed, will result in good code.


The point of the excercise it to append your name (length) from list indices.


If you follow the instruction and replace "myName.length" with "i + myName.length", it'll result in a wrong program. Example.


j should be equal to i. You must do what they tell you to, not just follow part of it.


It doesn't even check if j is equal to i at the start of the loop. If I fix the mistake with i+myName.length, it'll accept my code, even though it's wrong.

The essence of this part of the lesson is that we should add a loop with as many iterations as there are characters in myName. It shouldn't require writing the exact same code, it should only require the same results.