'Your second 'for' loop help!


#1

Please help! I can't figure out for the life of me what I am doing wrong!

var text = ("Jayne", "Eevee", "Jayne", "Fiona");
var myName = ("Jayne");
var hits = [];

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


#2

your second for loop:

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

why use i++? the second for loop from beginning till end of your name, to achieve this J should be increased


#3

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