When the click counter reaches 69 it should display "Nice" in the h4 bellow but i can only make it to show the else "error" message (the else message should be in blank " " but for testing i put a message)
HTML
<button type="button" onclick="myFunction()"> Clic to count +1 </button>
<h4 id="demo"> 0 </h4>
<h4 id="secret"> </h4>
Javascript
const add = (function () {
let counter = 60;
return function () {counter += 1; return counter;}
} )();
function myFunction(){
document.getElementById("demo").innerHTML = add();
if (add == 69){
document.getElementById("secret").innerHTML = "Nice";
}else{
document.getElementById("secret").innerHTML = "error";
}
}
The initial value of counter is 60 to make it faster to test