I'm working on a course project which I'm really struggling. I tracked the clicks of the user on a set of images, this is the n variable of my program and the maximum click number is 3. I want to redirect the user to another webpage when a button is clicked and the webpage that I'll redirect will be determined by the n variable, 1 - 2 or 3. The user will be redirected different pages when a button is clicked in terms of the n variable. I'm attaching my code below, please help. I want to add that the index parameter in the increment function attached to the images in the html code. Increment function is working without a problem also. For example I tried the case when the n = 1 and user clicked the button.
function increment(index) {
var n = 0;
if (n < 3) {
n++;
}
if (n == 1) {
document.getElementById("gameButton").onclick = redirect (increment(index)) {
location.href = "remaining8.html";
}
}