Uhm how do I do that array thing?


#1

In exercise 5th I have to make arroy in my second 'for' command. For some reason it doesn't work. Here's the code:

/*jshint multistr:true */

var text = "Hallo, I am crazy russian haker and velkom to my \
labratury were seifty is numbur une prijority"
myName = "Kristijonas"
var hits = []
for (var i = 0; i < text.length; i++){
if (text[i] === "K") {
for(var j = i; j > text.length + myName.length; j++){
hits = [];
hits.push(myName);
hits[0];
}
}
}


#2

your second for-lopp should look like this:

    for(var j = i; j < (myName.length + i); j++)
{
            hits.push(text[j]);
}

#3

That doesn't work for some reason... I get this error:

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.