How can I make my function not to repeat the multiple calls, if multiple calls were made in mins?
var s = 1;
function foo(x) {
if (s === 1) {
console.log('done');
setTimeout(function(){
s =1;
}, 10000);
} else {
s = 2;
console.log('no more repeat calling');
}
}
foo(1);
foo(2);
I am expecting the result -
done
no more repeat calling