5. Second for loop not working


#1


https://www.codecademy.com/courses/javascript-beginner-en-XEDZA/0/5?curriculum_id=506324b3a7dffd00020bf661#


Tried different suggestions, but keeps saying it's not pushing any values.


var text = "asdf asdf asdf asf James asdfasdfasdfasf James asdfasdf James asdf";

var myName = "James";

var hits = [];

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


#2

nevermind fixed it, changed text[0] to text[i]


#3