Second For Loop Isn't Pushing Values in Hits Array


#1

`/*jshint multistr:true */

var text = "My name is Cory, and Cory is my name.";
var myName = "Cory";
var hits = [];

for (var i = 0; i > text.length; i++) {

if (text[i] === myName[0]) {

    for(var j = i; j < (myName.length + i); j++) {

        hits.push(text[j]);

    }

}

}

console.log(hits);

Can someone please help find what is wrong with this code? It's driving me crazy...

EDIT: I figured it out. My first loop had a > rather than <...


#2

for(var j = i; j < (myName.length + i); j++) {

    hits.push('C' +myName.length);

#3

@iademoye, No his "hits.push" statement was correct. You can't get the result you're suppose to with what you're attempting, because what it will print to the console is "C4" when it's expecting ["C", "o", "r", "y"].