5. your second "for" loop problem


#1

i didnt understand what is the problem but it didnt work.can you help me please?
thank you...


 /*jshint multistr:true */
text = "bbb bbb eeee rrr ahmet \
kk.yyy ahmet uyt.";
var myName = "ahmet";
var hits = [];
for (i = 0 ; i < text.length ; i++){
    if(text[i] === "a"){
        for ( j === i ; j < i + myName.length ; j++) {
            hits.push(text[j]);
        }
    }
};


#2

Hi, you only have one problem, and it's easy to overlook.

The thing is, inside of this for loop, you do not want to compare j to i, you want to make this for loop (j) start at i. Basically, you would just want to set it equal to i instead of comparing it to.


#3

yes i see.thank you so much.i need to look more careful i think.thank you for quick answer too


#4

Awesome, I'm glad you got it to work!


#5

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