Your second 'for' loop


#1

i've been working on this for sometime but i keep getting the message that my second for loop isnt pushing values into hits array. this is my code

/*jshint multistr:true */
var text = "hello lesley \ how are you lesley"
var myName = "lesley"
var hits = []
for (var i = text.length; i < 0; i++); {
if(text[i] === myName[0]) {
for (var j = i; j < (i + myName.length); j++) {
hits.push(text[j])
}
}
}
console.log(hits);
console.log(hits.length);

it prints
[]
0


#2

This is messed up. Should be,

for (var i = 0; i < text.length;  i++) {

#3

that part was not even part of the phase i was to work on so didnt think i should touch it. i tried the above solution still brought the same result


#4

Try to check your semicolons! There is missing one after hits.push(text[j]);


#5

thank you, i had 1 semicolon at the first 'for' loop that i had to remove also. but my results werent perfect ,i got through though.will have to read more on this to understand.


#6

A post was split to a new topic: Creating never ending loops