Text ur name ex 5


#1


'for loops in java script' 'Search text for your name' ex5/7

I don't understand why my code doesn't work

var text = "Hey Micol. How are u Micol... we havent seen \ eachother in such a long time Micol.";
var myName = "Micol";
var hits = [];
for (var i = 0; i< text.length; i++){
    if(text[i] === myName[0]){
        for(i= j; j < (myName.length + i); j++);{
            hits.push(text[b]);
            }
        }
    }

#2

This section would seem to be the problem. In the if statement you need to === text[i] to your letter so in this case J. That letter needs to be in quotes as well. In your for statement you need var j = i; as shown in the examples given in the lesson. I believe that should do the trick


#3

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