I'm trying to change the opacity of each element in an array but with a slight delay between each element. I've tried a bunch of variations of the simplified code snippet below but each time either they all change at once with a delay or nothing changes. Whats the correct syntax for this code?
for (let i = 0; i < testArray.length; i++) {
setTimeout(function() {testArray[i].style.opacity = ".5"}, 500);
}