I have been trying for a good minute to figure out why my if statement never triggers. Any help would be much appreciated!
var clickcounter = 0;
var buttonclicker = document.getElementById("buttonclicker");
function unblur() {
clickcounter = clickcounter + 1;
console.log(clickcounter);
}
if (clickcounter === 1) {
buttonclicker.textContent = "Unlock More";
alert(clickcounter);
}
the variable clickcounter will be equal to or over 1. I at first tried using if (clickcounter => 1) and also tried if (clickcounter > 0) but none of this worked. What am I doing wrong? Here is a codepen of the whole thing: https://codepen.io/sage379/pen/JyppZv
clickcounterto 0 and then check if it's equal to 1. It's not 1, it's 0. Because it was just set to 0.unblur?unblurisn't called until something else calls it. Whereas yourifstatement executes immediately. Did you mean to put theifstatement in theunblurfunction?