Hi everyone
I have near-zero javascript experience, so I’m sure the solution to my problem is very simple…
I’m running the following js function on page load, which is working as expected:
function incrementValue() {
variables['e3a994ed-43a6-4fba-b225-46f369236104']++;
if (variables['e3a994ed-43a6-4fba-b225-46f369236104'] === 7) {
variables['e3a994ed-43a6-4fba-b225-46f369236104'] = 1;
}
}
let intervalId = setInterval(incrementValue, 4000);
I would like to cancel the recurring loop above when a button on the page is clicked. The current code for that button is:
clearInterval(intervalId);
Unfortunately, this button isn’t working.
I also tried to add to the page’s body script custom code based on ChatGPT guidance:
let intervalId;
Any guidance on what I am doing wrong?