I'm currently attempting to clear the interval within the slide.autoplay
function in this particular JavaScript snippet.
I would like to incorporate another function into my constant, such as a slide.stop
function.
slide = {
init: () => {
eraser.content()
slide.autoplay()
},
next: () => {
eraser.start()
currentSlide < 1 ? currentSlide++ : currentSlide = 0
eraser.content()
eraser.end()
},
autoplay: () => setInterval(slide.next, 5000)
}
addEventListener( 'DOMContentLoaded', slide.init )
addEventListener( 'click', slide.stop )
By the way, I have been using functions within constants for some time now and find it suitable. However, I am unsure if it is considered good practice. What are your thoughts on this?