Where is the error in the second for loop


#1

var text = "My name is Elijah derived from the bibles's Elijah \ the prophet who prached God's strength to non believers."
var myName = "Elijah"
var hits = []
for (var i = 0; i < text.length; i ++); {
if(text[i] === 'E') {
for (var j = i; j < (myName.length + i) ; j++); {
hits.push(text[j]);
}
}
}


#2

What makes you say that there's a problem in the first place? What behaviour are you looking to change about your code?

The difference between the current behaviour and what you want it to do instead probably says a whole lot about what you need to change.


#3

there are no values being pushed into the hits array


#4

Then either the line doing the pushing isn't doing its job or it isn't executed, right? How can you figure out which is the case, and what's the next thing to consider after that?


#5

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