Search Text for Your Name Q&A


#1

I am stuck on lesson 'Your second "for" loop' (5/7) :cry: The editor says that I have this problem: SyntaxError: missing ) in parenthetical Here's my JS code:

/*jshint multistr:true */
var text = "Hey, how are you \
doing? My name is camillita.";

var myName = "camillita";

var hits = [];

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

I sort of need help. Any suggestions?

Thanks :wave:


#2

++i or i++ means add 1 to i. You don't want to add one to i, you want to add i your names length, so you should use + sigin in your second for loop


#3

It worked! Thanks @stetim94
Just a quick question: Is it normal that the editor shows me a number? It showed me 9


#4

yea, it is. this line:

hits.push(text[j]);

j is a number, so it makes sense, in the next exercise you will print your name!