November 2017
Intermediate to advanced
386 pages
9h 22m
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 change it to true, and execute the function; otherwise, you don't do anything at all:
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 problems that must be addressed:
Read now
Unlock full access