First array
var danu = ["nu", "da", "nu", "da", "da", "da", "da", "da", "da", "nu", "nu"];
Second array
var abc2 = ["2", "3", "2", "3", "3", "2", "2"];
I want to replace all "da" from first array with the values from the second array 1 by 1 so i will get
["nu", "2", "nu", "3", "2", "3", "3", "2", "2", "nu", "nu"];
I want the fix only in Javascript. I tried using the loop metod
for (i=0; i<danu.length; i++) {
if (danu[i] == "da") {
danu[i] = abc2[i];
}
}
But i end up getting the array to this
["nu", "3", "nu", "3", "3", "2", "2", undefined, undefined, "nu", "nu"]