Let's say I have this code:
var a = ["a", "b", "c"];
a.forEach(function(entry) {
setTimeout(function() {
console.log(entry);
}, 1000);
});
This waits 1 second and then logs a, b, and c all at once. I want to wait 1 second, log a, wait another second, log b, wait a third second, log c.
How do I execute a for loop so that each loop takes a second, and the following loops don't start until that second is up?