Exercise 5. Your second "for" loop - I'm stumped


#1

I've looked at a bunch of the other posts on this lesson and I'm still completely stumped as to where I'm going wrong here... Any help would be greatly appreciated, I've been stuck for a couple hours.


/*jshint multistr:true */

text = "Hey, this is a string of text about Kit.\
Kit is learning how to code because Kit has some neat opportunities\
in her direct future if Kit keeps up her skillz.";

var myName = "Kit";
var hits = [];

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

Error: Oops, try again. There was a problem with your syntax.


#2

Very simple just remove this after myName.length


#3

In your second for loop


#4

Ok, I took out the "+i)" but now it gives me this error message:

Oops, try again. Careful: your second 'for' loop should stop when it reaches its current point in the string + myName.length.


#5

Oops, really sorry there didn't look at your code correctly,

Here's the format your for loop should have

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


#6

Ah! That did it. I swear I had that at some point when troubleshooting my code... Who knows. Thanks so much for your help! What a relief.


#7

No problem! You're welcome! :grin: