Search Text for Your Name infinite loop


#1

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

no error message...site crash with aw snap, something went wrong displaying the page


/*jshint multistr:true */
var text = "I am a child of God named Tanekqua.  God's daughter\
Tanekqua!!!"

var myName = "Tanekqua"

var hits = []

for(var i = 0; i < text.length; i++)
{
    if(text[i] === 'T')
    {
        for(var j = i; (j < i + myName.length); i++)
        {
            
            hits.push('myName'[j])
        }
    }
    
}


#2

Hi you go the infinit loop because of this line

for(var j = i; (j < i + myName.length); i++)

you should change the i++ with j++ then here

hits.push('myName'[j])

instaed of 'myNAme'[j] you should do text[j]


#3

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