Why won't it push into the array


#1


https://www.codecademy.com/courses/javascript-beginner-en-XEDZA/0/5?curriculum_id=506324b3a7dffd00020bf661


why will not it push into the array?
error:
It looks like your second 'for' loop isn't pushing values to the hits array. Make sure it's working properly and that myName's text appears somewhere in the text variable.


/*jshint multistr:true */
var text="fabian hi bye hello goodbye toot koot loot koot me he tee\
no lop fabian chin happy shappy rl stine kool aid lemonake tea \
grandpa hoot";
var myName="fabian";
var hits=[];
for(var i=0; i<text.length; i++){
 if(text[i]==="f") {
 for(var j=0;j>i+myName.length;i++){
hits.push(text[j]);
}    
}  
}.


#2

second for loop is buggy.

problem1.

var j = 0

The initial value of j should be equal to the index where the first letter of your name matches with text's character.

problem2
The condition of for loop is also needs to be fixed.

j>i+myName.length

problem3.

i++

Your loop variable is j ?


#3

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