# Stuck on your second "for" loop part

#1

``````**Can anyone tell me what's wrong with my code ? I'm stuck on your second "for" loop part**

/*jshint multistr:true */
var text = "Blah Blah Anubhav Blah Blah Blah Blah Blah Blah Blah Anubhav Blah Anubhav Blah Anubhav Blah Blah Blah Anubhav Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah";
var myName = "Anubhav";
var hits = [];
for (var i=0; i<text.length; i+=1) {
if  (text[0] === "A"){
for (var j = i; j < (myName.length + i); j++) {
hits.push(text[j]);
}
}
}``````

#2

It should be:
if (text [ i ] === "A") {
so that the code runs from where i is, which would be 'A', instead of just the start of text.

#3

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