Your second "for loop"


Don't understand what to do, here's my code:
/*jshint multistr:true */
var text = "My name is Mikasa, I am called Mikasa, I am Mikasa";
var myName = "Mikasa Ackerman";
var hits = [];
for (i = 0; i < text.length; i++) {
if (text[i] === 'M') {
console.log ("its equal");


You shuld not have a variable here:


I'm not sure what to do there


The instructions are:
Okay! Go ahead and add that second for loop inside the body of your if statement.


How should I define j


You have to add another for loop but instead of var i it should be var j


in your first for loop you defined i:

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

i = 0 is the definition of i, you will have to do something similar in the second for loop, to create the variable j (don't set j to 0), did you check some of the other topics on the forums? There are many questions about the second for loop (it is tricky), which means there are also some good explanations


ok ill have a look, thanks!


Good idea, if you need more help after a while, post an updated version of your code


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