#5.... help!


#1


I can't seem to get the arrays right, and I might have an infinite loop. Please help!

Before, it was saying that the array wasn't hitting values to the array, and to make sure myName showed up somewhere in the text. Then the browser started having trouble. Please help!!!

var text = 'askdjflhiasdhlfjhblasdkjbckdnJadeaskjdhfiasfhgkjnvkmnkdmhfhJadeklsdfa;ghoareioutfkdjhakjngvkcJadeskdgf';
var myName = 'Jade';
var hits = [];
for (var i = 0; i < text.length; i++){
    if (text[i] === 'J') {
        for (var i = 0; i <  myName.length; i++){
            hits.push(myName);
            hits[0];   
        }
    }
}


#2

you cannot declare 'i' twice. In the second loop replace 'i' with some other variable like 'j' or 'x' etc.


#3

That would make sense.:smile: i feel like an idiot


#4

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