Pushing hits unsucsessful


#1

Hi. Ive been working on this code for a while now and i want to know why does the site says "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." and no error is returned on the console.
Here is my code:

var text = ("Yo Amit how are you today I like Amit because Amit is the best");
var myName = ("Amit");
var hits = [];
for (var i = 0; i < text.length; i++); {
    if (text[i] === "A") {
        for (var a = i; a < (myName.length + i); a++); {
            hits.push(text[a]);
        }
    }
    else {
    }
}

Thanks for the support.


#2

After your for() {} conditions you are ending them with ; so it's not executing the code. You have it setup like this: for () ; {} - so it never executes the code block. Remove ; after your for conditions () and remove else { }} and just add a third } below hits.push


#3

var text = ("Yo Amit how are you today I like Amit because Amit is the best");
var myName = ("Amit");
var hits = [];
for (var i = 0; i < text.length; i++) {
if (text[i] === "A") {
for (var a = i; a < (myName.length + i); a++) {
hits.push(text[a]);
}
}
}
console.log(hits);

//Like this


#4

Thanks very much!!! ;D