I want the function to run only once on the first click and no more. But I get an error that someVar is not defined, that is what I have included in the condition. Why is it giving the error? How to solve it?
button.onclick = function () {
if (someVar == undefined) {
console.log("Hi");
someVar = 1;
}
}
Aucun commentaire:
Enregistrer un commentaire