Your second "for"l loop. Stuck


#1

I do not know what I am doing incorrectly.
/*jshint multistr:true */
var text = "Man that Justin guys is cool. Justin \
awesome. I wish I was Justin!"
var myName = "Justin";
var hits = []
for (var i = 0; i < text.length; i++);
if (text[i] === "J") {
hit = i++;
for (var j = i; j < i + myName.length; j++);{
hits.push(text[i]);
}
}


#2

What does this line execute?


#4

/*jshint multistr:true */
text = "Man that Justin guys is cool. Justin \
awesome. I wish I was Justin!";

var myName = "Justin";
var hits = [];

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

Here are my corrections. I hope it makes sense and helps you.
-delete var before text (first line)
-add ; at the end of text
-add ; at the end of var hits
-delete ; at the end of your first for, and add in a {
-delete hit = i++
-move + i (within your second for) and place it after myName.length
-delete ; that is outside the () on your second for (and before the { )
-add one more } after hits.push(text[i]);


#5

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