Currently, I am working with an array that contains 'n' amount of objects (let's assume n = 1), along with a forEach function that triggers another function each time it iterates through the array. The challenge I'm facing is the need to assign each index integer of the array to a variable so that I can pass them into other functions. Is there a method someone could recommend for achieving this requirement without necessarily using a forEach loop?
I have experimented with setting the index of the array to a variable, but it seems to resolve to the final index value in the end result. However, what I actually need is to store every individual index within a variable.
let tasks = {"options":[{"headless":false"},{"headless":true}]};
tasks.options.forEach(function(value, int) {
//The associated function executes at each iteration
main();
//At this point, if two objects exist, the variable 'check' always ends up being '1'. My goal is to concurrently hold values from both tasks.options[0] and tasks.options[1].
let check = tasks.options[int]
});