Your second "for" loop


I really don't understand what I'm doing wrong. Help me.

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 = "mike mitiklf fsdlf dkfs sdf";
var myName = "Mitul";
var hits = [];

for (var i = 0; i < text.length; i++) {
    if (text[i] === "M") {
        for(var j = i; j < (myName.length + i); j++) {


Did you define a variable text ??
Could you provide us with the variable.....??


My apologies, missed it in the copy, paste. I've updated it and it's in now.


Try it by using

var text = "mike mitiklf Mitul fsdlf dkfs sdf";

where your name is at least once mentioned.....


Oh, should have used my brain there. Thank you!


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