For the Simon Game project,
I currently have a start button that randomly chooses colors to put into an array,
then I pass the array into a function that iterates through the array and
uses the color variable as the selector to change the color.
The issue I am having is that the $(selector).trigger(“click”) is not executing in the
same order as the order in the array.
ex: color_array = ["#blue","#red", “#green”,"#red"] when passed to a function containing
$(color).trigger(“click”)
it executes where blue, red and green executes simultaneously,
then red executes.
Rather than blue then red then green then red.
I know it might have something to do why the asynchronicity of .trigger vs the synchronicity for-loops
but I tried to use setTimeout() and had the same result.
I also explored using .queue() but I only found examples where the animation is only done on one element.
See the Pen simon by Justo Guillermo Montoya (@justoMontoya) on CodePen.
In short, how do I make $(color).trigger(“click”) in the order of the color array?