Your second "for" loop


#1


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

Good morning code men and women. Kindly someone tell me where I am going wrong in my code. I cant progress. Thanks.


Oops, try again. There was a problem with your syntax.
SyntaxError: missing } in compound statement

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

`


#2

Still waiting, somebody please assist. Thankyou.


#3

this two lines:

   for (i = 0; i == text.length; i++){
    if (text[i] === 'j'){

why do you have them? They seem duplicates of the two lines above, i suggest you remove them

Also, did you declare a text, myName and hits variable?


#4

Yes, I have declared the three variables. Here is my complete code:

var text = "How are you? My name is Vesela.";
var myName = "Vesela" ;
var hits = [] ;
for (var i = 0; i < text.length; i++) {
if (text[i] === "V") {
for (i = 0; i === text.length; i++){
if (text[i] === 'j'){
for (var j = i; j < (i + myName.length); j++){
hits.push(text[j]);
}
}
}


#5

It seems am not getting clearly what is required. Kindly explain, thanks.


#6

you have two loops to loop over text, you only need one:

var text = "How are you? My name is Vesela.";
var myName = "Vesela" ;
var hits = [] ;
for (var i = 0; i < text.length; i++) {
  if (text[i] === "V") {
  // removed the duplicate loop
     for (var j = i; j < (i + myName.length); j++){
           hits.push(text[j]);
        }
    }
}

#7

Thanks much I appreciate. I am grateful for your support. :relieved::relaxed:


#8

It works I am glad for your help.


#9