Loop


#1


what is the problem here

var text = "Abijith hai abijith and also abijith";
var myName = "Abijith";
var hits = [];
for(var i = 0; i < text.length; i ++)
if (text[i] === "A");
for (var j = i; i < hits.length ; i
+myName.length);
{
}


#2

please read some of my older detailed answers (click them and scroll down):


The problem with your loop is serious. You don't seem be understanding it. You want to loop over your name, which means you start at i (which you did, very well) then until the end of your name (i + myName.length) by increasing j.


#3

thank you for helping.
i am new to java.
and codecademy really help me to learn it.


#4

Did you figure it out?

Java is to javasript what ham is to hamster, they are completely different languages mostly used for different purposes.


#5

so now i am learning javascript.


#6

Yes, you are learning javascript.


#7

which is java....................


#9

what is the problem now
..........................................................

var text = "Abijith hai abijith and also abijith";
var myName = "Abijith";
var hits = [];
for(var i = 0; i < text.length; i ++){
if (text[i] === "A");{
for (var j = i; j <myName.length + i; j++);
}
}


#10

semi-colons at the end of a if condition and a for loop:

if (); <- bad idea
for (); <- also a bad idea

inside the for loop:

for (var j = i; j <myName.length + i; j++){

}

you have to push the letters (text[j]) into hits arary


#11

thanks a lot.
now its done....


#12