Second 'for' loop isn't pushing values to the hits array


#1

I cannot seem to push the text from myName to the array.

/*jshint multistr:true */
text = "blah blah blah blah Caleb \ blah blah blah blah blah \ Caleb blah blah";
var myName = "Caleb";
var hits = [];
for(var i = 0; i < text.length; i++){
    if(text[i] === "C") {
        for(var j = i; j < text + myName.length; j++){
            hits.push(myName)
        }
    }   
}

#2

you need to do hits.push(text[j]) here instead


#3

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