Reputation: 6271
I need to append the values of fStr1 to some variable.This is my code.
var myCars=new Array();
for(i=0;i<companyLength;i++)
{
var othercompanies=new Array();
othercompanies=companyrealObj[i].innerHTML;
var fStr=othercompanies.split(">");
var hreflink=fStr[0].split("\"");
var fStr1=fStr[1].split("<");
obj['name'+companyLength] =fStr1[0] ;
myCars.append(fStr1[0]);
}
alert(myCars);
here let say the companyLength=2 then the loop will be executed for 2 times.fStr1[0] will contain two values.Let say Hello1 and Hello2. I am appending the fStr1 to the myCars.But the problem is when I print the myCars it contain Hello2 only.Can anyone help me how to append the values of fStr1[0] to myCars.
Upvotes: 0
Views: 1620
Reputation: 5207
I think the function you're looking for is .push()
so your code to append to the array should be:
myCars.push(fStr1[0]);
Upvotes: 0