I have pre-existing two arrays on the webpage that I need to customize, one with strings and other with corresponding id's. I need to replaces the strings in array1 based on the information I get using array2. I have problem looping through array1 as it only gives me length = 1 in all cases.Why so? Is there any better way to accomplish this task? I will appreciate any help I can get. Thanks
var arr1= [[ "Khyle", "Marlen", "Jose"]];
var arr2= [[ "51", "69","22"]];
//replace extra square brackets
var str = arr2.replace((/[\[[']+/g,'[');
str= str.replace((/[\]]']+/g,']');
var length = str.length, element = null;
for (var i = 0; i < length; i++) {
element = str[i];
// Ajax call to get the info and load in arr1[i]
arr1[i] = ajax-str
}
replacea String method? You're calling it on an array