+ 2
how do you call a function in javascript until two buttons are clicked before the fuction executes?
click on two buttons before the function is called
4 odpowiedzi
+ 1
var flag1, flag2;
btn1.onclick = () => {
flag1 = true;
if (flag2) myfunc();
};
btn2.onclick = () => {
flag2 = true;
if (flag1) myfunc();
};
+ 1
Francis Woli obviously, you need to reset both flags (in function called or in if block) to false for enabling multiple calls...
0
PSEUDOCODE
-----------------------
btn1.onClick keyOne = true
btn2.onClick keyTwo = true
if(keyOne && keyTwo)
callYourFunction()
0
how do apply it to event listeners?