Adding Iterator crashes the webpage


#1


https://www.codecademy.com/courses/javascript-beginner-en-XEDZA/0/5?curriculum_id=506324b3a7dffd00020bf661#


When I add j++ to the last for loop, the webpage crasshes. When I don't add it, the code says I'm wrong.


/*jshint multistr:true */
var text = "Shrike rhjdl;afajd;va'afojvbamld,ng;afvl;acb'a";
var myName = "Shrike";
var hits = [];
  for (var i=0; i<text.length; i++) {
      if (text[i]===myName[0]) {
          for (var j = i; j=i+myName.length; j++) {
              hits.push(text[j]);
          }
      }
  }


Unexpected token ) AGAIN
#2

the condition of your second loop:

j=i+myName.length

you set j to a value of myName.length + i? that is not really a condition, j should continue to increase until it is no longer smaller then (<) i + myName.length


#3

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