Stuck on the Second For Loop


#1


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


I have modified this code many times for spacing, switching the inequality, and even copying the exact code of the second 'for' loop from the example at the beginning of the lesson and I cannot figure out what is wrong. It keeps giving me the error message of:
"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."

It's probably something small and stupid that I'm missing, but it doesn't explain very well how to use the push() method but I think I get it. I've even refreshed the page to see if it was some sort of glitch.


/*jshint multistr:true */

var text = 'Lorem ipsum dolor sit amet, consectetur Pat adipiscing elit. Sed pulvinar ex ac ipsum sagittis venenatis. Nam leo Pat orci, sagittis eget diam a, ultrices auctor arcu.';
var myName = 'Pat';
var hits = [];

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


#2

I'm an idiot my bad
first for loop inequality was wrong, not the second one


#3

#4

good you solved it yourself, that is better, you learn more from it :slight_smile: