Here I got a function which I need to re run everytime I click button for previous or next. It was working fine but I wanted to refactor my code to use a array object but I don’t know how to insert parameter
following is my code
let count;
const generateHTML = () => {
data.images.forEach((el, index)=>{
viewport.innerHTML = `
<img class='carousel img-fluid' src="./img/${index}.jpg" alt="">
<div class="slides">${index +1}</div>
`
})
}
on next button I want to run generateHTML(count++)
and on previous generateHTML(count--)
How can I pass argument so that the Array.forEach has access to it and can increment/decrement index