5/7 Whats wrong?


#1
/*jshint multistr:true */
var text="jandj Kaspars asdjnaskd asdbasd asdjnadjand \
aksdmlkasd asdaslkd asdkasd asdkmaskldmasd akls \
asdkasldk Kaspars asdn asjdnas adhbasd ashd ha sdhb Kaspars";
var myName="Kaspars";
var hits= [];

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

It would be great if someone could help me! Dont get whats is wrong, but it keeps saying :
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.


#2

First of all, I think you should replace the "E" in your if statement to a "K", for there is no "E" in your name. AND, do

console.log(hits);

so it prints it.


#3

Oh, thanks! Did that, but still, nothing. The same error.


#4

/*jshint multistr:true */

var text = "Don, yo Don yo Don yo Don";
var myName = "Don";
var hits = [];

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

    }

}

It won't work says the same message as the person above


#5

Hey donovans! You got the wrong comparator:

Instead of

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

You put

See the ">" sign? That makes it already true, so it does not function.

Hope it helped!:smiley:

P.S. @byteblaster33754! I believe you have the same problem there.


#6

THANK YOU SO MUCH... You have no idea how long I agonized over this.


#7

You've written the first loop wrong. You need the "<" sign, not ">".


#8

OMG, thank you so much! :smile: