How can I call function2 after function1 finished every 5 times?


(chans) #1

Hello
I want to call function2 when I call function1 every 5 times.
I tried this code but it did not run.
Can you help me?
Thank you so much.

function function1() {
if(window.clickCounter == null) {
window.clickCounter = 0;
}

if(window.clickCounter < 5) {
function1();
} else {
function2();
}

window.clickCounter += 1;

}