January 2020
Intermediate to advanced
470 pages
11h 13m
English
The solution most people would probably think of first is using some global variable to record whether the user has already clicked on the button. You'd define a flag named something like clicked, initialized with false. When the user clicks on the button, if clicked was false, you'd change it to true and execute the function; otherwise, you wouldn't do anything at all. See all of this in the following code:
let clicked = false;...function billTheUser(some, sales, data) { if (!clicked) { clicked = true; window.alert("Billing the user..."); // actually bill the user }}
This obviously works, but it has several ...
Read now
Unlock full access