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


#1


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.
I can't get past this challenge.Waht's wrong with my code?


/*jshint multistr:true */
var text = "I am the World's greatest Full Stack Developer CEH CCNA CCNP LPT CCIE CISSP Timothy Timothy Timothy";
var myName = "Timothy";
var hits = [];
for (i = 0; i < text.length; i++); {
if (text[i] === "T") {
for (var j = i; j < (myName.length + i); j++) {
            hits.push(text[j]);
}
}
}


#2

Your j variable adds letters to the array. And your i veriable looks for compariables cases. So, in the last line of code you should have:

hits.push(text[i]);


#3

@igorshkarin i changed my code to hits.push(text[i]; but iam still getting the same error


#4

Look, one more tiny mistake:

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

Delete the semicolon in your first for loop before curly brace.


#5

Seems, like I was wrong. I'm trying to get understanding of this lesson.
My first suggestion was wrong, I guess. You can left there "J";
The second advice about semicolon - correct.


#6

@igorshkarin,thanks you so much. are right about the semi colon in my first for loop.my code worked just fine without it.as for the hits.push(text[i]); or hits.push(text[i]); they both work just fine.


#7

thats exactly what happened to me :confused: how do i fix it?


#8

I thought we solved the problem above.
Where you stucked?


#9

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