5. Your second "for" loop **PLEASE HELP!**


#1



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


PLEASE HEEEELP. I've been stuck for hours and I can't seem to understand my mistake!

I tried everything. It keeps writing:
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.

Please haaalp :cry:


/*jshint multistr:true */
var text = "Eve Eve Eve Eve Eve";
var myName = "Eve";
var hits = [];
for (var i=0; i<text.length; i++); {
    if (text[i]==="e") {
        for (var j=i; j<myName.length + i; j++) {
            hits.push(text[j]);
        }
    }
}


#2

Hi this line remove the ; at the end

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

then in the if statement

if (text[i]==="e")

the if statement should check for the first letter of your name , remember that you wrote "Eve"


#3

THANK YOU!!! It's just like you just saved my life!!! :smiley:


#4

Também você pode fazer assim:
/ * jshint MULTISTR: true * /
var text = "Eve Eve Eve Eve Eve" ;
var myName = "Eva" ;
var sucessos = [];
for(var i = 0; i < text.length; i += 1) {
if(text [i] == "Eva");
for (var j = i; j < (myName.length + i ); j += 1) {
hits.push (text [j]);