5/7 can't find answer..?


#1
/*jshint multistr:true */
var text="blah blah blah blah blah blah blah Rémy blah blah blah blah blah blah blah blah blah Rémy blah blah";
var myName="Rémy";
var hits=[];
for (var i=0; i<text.length; i++); { 
    if (text[i]===myName[0]); {
      for (var j=i;j<i+myName.length; j++); {
          hits.push(text[j]);
        }
    }
}

"Oops, try again. Make sure you're pushing letters to the hits array!"

???


#2

Study the following to see where your errors are in the above:

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

#3

thanks mtf, but for some reason my code was not showing properly, what you quoted from my code block doesn't look like what I actually wrote at all..( I think I used the wrong quotes ?).. I think I fixed it, now you should see the whole code block I wrote.. can you please have a second look ?


#4

hey mtf , I still found the answer thanks to you ! I compared both code blocks, and my errors where the (damned) semicolons before the { !! here is what my final correct code block looks like. thanks a lot !

/*jshint multistr:true */
var text="blah blah blah blah blah blah blah Rémy blah blah blah blah blah blah blah blah blah Rémy blah blah";
var myName="Rémy";
var hits=[];
for (var i=0; i<text.length; i++)/*no need for ;*/ { 
    if (text[i]===myName[0])/*no need for ;*/ {
      for (var j=i;j<i+myName.length; j++)/*no need for ;*/ {
          hits.push(text[j]);
        }
    }
}

#5

is where the error is in both for statements.

Edit: I see you got that already. Good catch!