I have a list of divs I am iterating through. I think I figured it out using async/await:
let list = document.querySelectorAll('div')
async function goThrough() {
for (let x = 0; x < list.length; x++) {
let foo= await new Promise(resolve => {
setTimeout(() => {
console.log(x)
resolve();
}, 5000)
});
}
}
goThrough();
This seems to be logging each div node in the list with 5 seconds between them. I can't figure out how to do this using straight Promises though, without the luxury of async/await. I'm fine using async/await but curiosity has gotten the better of me and just trying to break it down to see if I can do it without it.