Dont understand whats wrong with this code HELP! please


okay so ive looked at all of this section for a fix but still have not found one, another pair of eyes may help my situation.

/*jshint multistr:true */

text = "lou blah blah lou blah blah lou blah blah lou";

myName = "lou";

hits = [];

for ( i = 0; i < text.length; i++ ); {
if (text[i] === "l") {

for (var j = i; j <  myName.length + i; j++) {





This is what i get back, i did get unidentified in an array at one point but now just this.


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.

help would be appreciated thank-you.


unnecessary semi-colon after i++), this will interrupt the loop

also, you are pushing text[i] to to your array, why? we use the second for loop to get your name from text string, so you j contains the indexes of your name


perfect, i did not mean to put the [i] ive just changed it so many times from other peoples answers... my actual mistake was the ; which i see was a silly mistake my bad. thanks


important lesson: Whenever you read articles/questions/wikis, always question it (what will this change do? Is this desired for my code? How does it work?)

don't just copy paste it

That would be so nice, if programmers don't make silly mistakes, unfortunately it happens (even experienced programmers)


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