I don't understand what to do? Lost :(


#1

I have somewhat idea of what I'm doing but I'm still stuck to what's happening here???
I did my bit of coding and looked around the forum if I was doing something wrong...
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.'

This is how my code looks: 
var text = "blah blah blah blah blah Nikhil, blah blah blah blah blah blah Nikhil, blah blah blah blah blah Nikhil";
var myName = "Nikhil";
var hits = [];
for (i=0; i===text.length; i++){
    if(text[i] === myName[0]){
        for (j=i; j < (i+myName.length); j++){
        hits.push(text[j]);
        }
    }
}
console.log(hits);

#2

Hi this line

for (i=0; i===text.length; i++)

this part

i===text.length

you should change === with < because i will never be equal to text.length


#3

Worked like a charm! Thanks A Lot!


#4

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