Please help me!


#1




The result shows just like this. [ 'a',
'm',
'e',
' ',
'a',
'm',
' ',
'a',
'a',
'n',
'd',
' ',
'a',
'.',
' ',
'A',
'a',
'm',
' ',
'i',
'a',
'm',
'e',
'.' ]


/*jshint multistr:true */
text="Hello, my name is Adam and i'm from China. Adam is my  name."
var myName="adam"
var hits=[]
for (var i = 0; text.length > i; i++) {
    if ( text[i] === "a") {
        for(var j=i;j<myName.length+i;j++)
            hits.push(text[j])
        }
    }

   if(hits.length == 0) {
        console.log("Your name wasn't found!")
    }
    else {
    console.log(hits)
    }


#2

The output is correct as expected. Only thing to consider... Names are proper names meaning we capitalize them out of formality. Set your name to Adam and search for "A" or myName[0] in text.


#3

Thank you! I got it right!