Second "For" loop won't work. Crashed browser


#1

Need some help finding out why my browser keeps crashing. I have attempted to find the answer on my own only to be met with no results that seem to fix the problem.

If i change my comparator in the second "for" loop to j > myName.length + 1; i++...... it does not crash my browser but displays the following error message...... "Oops, try again. 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."

Thanks for all help in advance.

/*jshint multistr:true */
var text = "Hello, I am a string containing text. My name is Bryce, but yours isn`t.";
var myName = "Bryce";
var hits = [];
 for (var i = 0; i < text.length; i++) {
     if (text[i] === "B"){
     for (var j = i; j < myName.length + i; i++) {
             hits.push(text[j]);
             console.log(hits);
         }
     }
 }


#2

The increment should be j++.


#3

Thanks so much mtf! Wow, I guess i`ve experienced my first time where I should have just walked away for a little bit. Compared the code to several others and skipped over that every time!


#4

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