I want to be able to run through a 'sequence' array and add additional time to the setTimeout() function so that each time it runs through the array the timeout is 600ms, then 1200ms, 1800ms, etc. The directions for the problem say to use 'delay' as a second argument in the setTimeout() function. Here is my code:
let delay = 0;
sequence.forEach((color) => {
delay += 600;
setTimeout(activatePad(color), delay);
});
I've also tried this as a solution as well, but it was exhibiting the same behavior:
let delay = 0;
sequence.forEach((color) => {
delay += 600;
setTimeout(activatePad, delay, color);
});
Instead of having a timeout, it is running all of the colors/sounds from the activatePad(color) function at the same time.
I was expecting to have each pad clicked and activated individually with a progressing timeout of an additional 600ms timeout each iteration of the loop. Instead they are all running at once.