Fails at Push


i am unable to complete the exercisw -Search Text for Your Name - Your second "for" loop. Please help me understand my mistake

error observed
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

var text = "my name is swetha \ sriraman";
var myName ="swetha";
var hits =[];
for (var i=0;i < text.length; i++ )
{ if (text[0] ==='s') {
    for (var j=i;j=i+myName.length;j++)


this condition:

{ if (text[0] ==='s')

is always false, the first letter of text is an m

hint: we use our first for loop to loop over all characters in text


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