Your second "for loop"


#1

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') {
var
console.log ("its equal");
}
};


#2

You shuld not have a variable here:


#3

I'm not sure what to do there


#4

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


#6

How should I define j


#7

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


#8

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


#9

ok ill have a look, thanks!


#10

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


#11

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