Second for loop


#1



https://www.codecademy.com/courses/javascript-beginner-en-XEDZA/0/5?curriculum_id=506324b3a7dffd00020bf661#


Hello, my name is Dominik,
I'm in this exercises, i've written my code, but it keeps telling me this:
"Oops, try again. Make sure you're pushing letters to the hits array!"
Can somebody help? Thanks for your time!

/*jshint multistr:true */
var text = " My name is Dominik, why Dominik? You would ask, \
because my parents thought that 'Dominik' was a good name. ";
var myName = "Dominik";
var hits = [];
for (var i = 0; i < text.length; i++) {
    if (text[i] === myName[0]) {
    
        for (var j = i; j < i + myName.length; j++) {
            hits.push(myName[j]);
        };
        
    };
    
};


#2

HI this line

hits.push(myName[j]);

where you have myName[j] it should be text[j]


#3

Thank you a lot! You are always behind my back! Can I help you in some way?


#4

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