2nd 'for' loop


#1


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

I'm trying to understand why it isn't pushing any text to the hits array. I have looked at other topics bt I'm still not understanding. I'm very new at this, and possibly not understanding the entire concept. Thanks for the help.

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.

Replace this line with your code. 

/*jshint multistr:true */
var text = "Hey guys I'm Drew, I'm a homosapien, more or less. Drew has evolved over many thousands of years to become the computer using weirdo Drew he has become today!";
var myName = "Drew";
var hits = [];


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


#2

Remove the semi-colon from both of the above lines.


#3

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