I'm working on a project where I need to display a series of slides, each with a specified display duration. My idea is to store these slides in an array and loop through them, showing each slide for the correct amount of time before moving on to the next one.
Here's my approach:
for (let i= 0; i < this.slides.length; i++) {
setTimeout(() => {
this.currentSlide = this.slides[i]
}, this.slides[i].slidetime * 1000);
}
I even experimented with this alternative method:
for (let i= 0; i < this.slides.length; i++) {
this.currentSlide = this.slides[i];
this.wait(this.slides[i].slidetime);
}
wait(seconds) {
setTimeout(() => {}, seconds * 1000);
}
Unfortunately, neither of these approaches worked as expected.