I am facing a challenge with a method (exampleObj.method) that requires arguments of an object and a function. The code snippet is as follows:
exampleObj.method({
name1: 'string1',
name2: 'string2',
name3: 'string3',
name4: {
array1: ['item1a', 'item1b', 'item1c'],
array2: ['item2a']
},
name5: exampleObj.method2
},
function exampleFunc(arg1, arg2) {
// function logic here
}
};
My goal is to run the method multiple times, with each iteration replacing array1 with a different array from the arrayCollection variable in a sequential order.
var arrayCollection = [
['item1d', 'item1e', 'item1f'],
['item1g', 'item1h', 'item1i'],
['item1j', 'item1k', 'item1l']
];
I understand that I can achieve this by iterating through the arrayCollection array and running the method each time, or potentially using forEach. My challenge lies in updating the value of array1 with each execution of the method.
My research has hinted at the use of array.map, but I am unsure how to utilize it to modify the specific array1 value in this context.
I would greatly appreciate any suggestions or guidance on how to tackle this issue!