Second loop not pushing to the hits array


#1


getting the error Oops, try again. It looks like your second 'for' loop isn't pushing values to the hits array. Make sure it's working properly and that myName's text appears somewhere in the text variable. and have been unable to figure out whats wrong with my code, any help on this would be appreciated


/*jshint multistr:true */
var text = "Clinton textetgowsjhfdsohfodsij odsif nodsifh dsofdsoifdosfih  Clinton Djhfisfhoiah";

var myName = "Clinton";

var hits = [];

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


#2

Reverse the operator to less than, < so the condition is true, some of the time.


#3

this crashes the page, which I presume means its infinite?


#4

Good. We're on to the next problem. After the condition, did you increment j or i? It should be j.


#5

ahh, thank you. legend


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.