Part 5 Your second 'for' loop


#1


OK, so. Been trawling through the forum and reading your people issues with this part of this course and I can't see where I've made my boo-boo (which undoubtedly I have). Any of you real coders want to take a gander and see where the issue is?
FYI: I included the snippet of code from the example for reference. I don't keep it in when submitting.


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


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


/*jshint multistr:true */
var text = "In diam diam, molestie Devon nec ullamcorper id, condimentum \
id mauris. Sed lacinia libero Devon vitae massa hendrerit vitae porttitor \
mauris porta. Praesent Devon dapibus vestibulum semper. Aenean posuere \
suscipit accumsan. Phasellus ac arcu Anthony Devon arcu. Phasellus sodales \
venenatis mollis. Fusce dignissim Devon mollis tortor sed fermentum. \
Pellentesque egestas, Devon mi accumsan  Anthony tempor, justo felis.";
var myName = "Anthony";
var hits = [];

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


// Below is the code from the example which ran successfully when I put it in place of mine but I can't see the difference other than the letter "E". Help?
for(var i = 0; i < text.length; i++) {
	if (text[i] === "E") {
		// If we find it, add characters up to
		// the length of my name to the array
		for(var j = i; j < (myName.length + i); j++) {
			hits.push(text[j]);
		}
	}
}


#2

Hi this Line remove The ; ..

for (var i = 0 ; i < text.length ; i++); <== this one

#3

Thank you! very much appreciated. Wrecks me how silly mistakes can cause so much frustration! :smiley: