It looks like your second 'for' loop isn't pushing values to the hits array


#1


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


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.


/*jshint multistr:true */
var text = "asd asd asd asd Topi opdifg sdfsdf sdlfiösdf Topi";
var myName = "Topi";
var hits = [];

for (var i = 0; i > text.length; i++){
    if(text[i] === "T"){
        for(var j = i; j < (i + myName.length()); j++){
            console.log(text[j]);
            hits.push(text[j]);
        }
    }
}


#2

.length is not a function. It is an attribute of the string object.

Recommend remove before submitting. It might not pass.


#3

Thanks! :slight_smile:


#4

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