Creating never ending loops


#1

I've been having trouble with this code, creating never ending loops. Any help?

/*jshint multistr:true */

var text= "huolj jju rde\ rfcm uyin frfcr Zach\ jruxd fjhrui\ cjnzis j Zach jdj\ jksdujfj cjnm Zach";

var myName= "Zach";

var hits=[];

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


Your second 'for' loop
#2

There are two major errors in the above:
1. i < ...
2. i++);

It should read,

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

#3

What @mtf said up there and the fact that you have to push your array.. for the task... Like this:

hits.push(text[j]);

#4

Sorry for the late reply, but all of that helped! Thank you everyone!