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


#1


'For' Loops in JavaScript > Search Text For Your Name


ERROR MESSAGE: 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.


Replace this line with your code. 
/*jshint multistr:true */
var text = "Vorrei che Dario riuscisse ad insegnare a Dario\
come programmare bene DarioJs";
var myName = "Dario";
var hits = [];
for (i=0; i < text.length; i++);
    if (text[i] === "D")
    {
        console.log= i;
        for ( var j=i; j < (myName.length + i); j++); {
            hits.push(text[j]);
        }
        
    }


#2

for (i=0; i < text.length; i++); // unnecessary semi-colon
for ( var j=i; j < (myName.length + i); j++);  // unnecessary semi-colon

and your first for loop is missing curly brackets


#3

console.log= i;
this line!

update**

start it again as it includes syntax errors! (mentioned by Mod)


#5

thanks! I don't know what it was the actual problem but I did everything you said and now it works!

thanks all guys!


#6

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