I want the value of offset variable to increase by 10 whenever the button is clicked. Currently, when I click on the next button, I get 2 lines: 0 and then 010. How do i get the value to change only when the button is clicked, and incremented at each click?
const New = () => {
// extract query parameters from url
const queryStr = '?offset=0&limit=5'
const usp = new URLSearchParams(queryStr)
let newVar = usp.get ('offset')
console.log(newVar)
// Set increment
let offset = newOffset += 10
console.log('new', offset)
}
const next = document.getElementById("next");
next.addEventListener("click", (event)=> New());