Second for loop, What's wrong


var text = "snuffy";
var myName = "Elmo";
var hits = [ ];

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

/*jshint multistr:true */

Replace this line with your code.


In your second loop you are to be checking if j is less than the myName variable and not i

[quote="cjudd42, post:1, topic:68853"]
i < myName.length


j < (myName.length + i)


Changed that still get the same 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.


Does anyone have the correct code, I can't get this to work at all.


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