Your second "for" loop


#1

I can't figure out what is wrong with my code. Tried to look at other solutions but can't figure where I went wrong.

/*jshint multistr:true */

var text = "Hello David, My name is David and I am just being David.";

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

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


#2

@snaildude,

1

The condition in your 1st FOR-loop should look like

i < text.length

2

The condition in your 2nd FOR-loop should look like

j < (i + myName.length)