6.5 Second loop


#1

I have already looked up what's the correct answer, but I just want to understand what's wrong with my code and the entire for/loop thing and I can't...

var text = "Hey Bob";
var myName = "Bob";
var hits = [];

for (var i = 0; i > text.length; i++) {
if (text[i] === "B") {
for (var j = i; j > i+ myName.length; j++) {
hits.push(myName);
}
}
}


#2

@javamaster02407 This is what my answer was if it was layed out like yours.

/*jshint multistr:true */
var text = "Hey Bob";
var myName = "Bob";
var hits = [];
for(var i = 0; i < text.length; i++){
if(text[i] === "B") {
for(var j = i; j < i + myName.length; j++) {
hits.push(myName)
}
}
}

Now I believe your issue was that instead of you using a "<" you used a ">" which makes the computer think that it is already at its stopping point in its for loop so it does nothing.