5/2 for loop 2


#1

i'm not really sure what im doing wrong here...can someone help?

var text = "blah blah blah!.";
var myName = "Josh";
var hits = [];
for ( i = 0; i <= text.length; i+=1) {
if(text[i] === 'J') {
for (var j = i; j < i + myName.length; j++) {
hits.push(text[j]);
}
}
}

this is what i'm putting in...


#2

Do you mind editing your code so that it is censored prior to posting on the forums? These forums are clean, to the best of all parties involved.

Second, your name has to be in var text, so just edit your text and add "Josh" somewhere in the text variable.


#3

haha sorry about that. I forgot I even had that. Thanks for the help!