Numbers output


Good evening,
If somebody would be so kind and tell me what I did wrong. Please don't swear on me, everybody can make mistake. :slight_smile:

It gave me badges and let me go to next exercise but I wanna know why in output i got numbers and not letters.

var text =  "zed, neo";
var myName = "neo";
var hits = [];

for (i = 0; i < text.length; i++) { 
if (text[i] ==="n") {
    for (var j = i; j < i + myName.length; j++) {
        hits.push (i);
    if (hits.length === 0) { 
        console.log("Your name, wasn't found!")
   else {


that would suggest you push the wrong thing into the array:

hits.push (i);

why did you choice to push i into the array?


Because for j was in if i, just as child to daddy


sorry, what do you mean?


for loop is inside if statement, that's why I choose it


but you use the second for loop (j) to find your name in text, so then j contains the indexes of your name in text, so then text[j] provides with the letters (using square brackets to access string by index)


[ 'n', 'e', 'o' ]
got it, Thank you!