javascript - setTimeout runs twice after the first iteration -


    (var i=0; i<sequence.length; i++) {         allowclick=false;          function playtimeout(n) {             settimeout(function() {                 _bubis[n].clicked();              }, i*1000+750);         }          settimeout(function(){allowclick=true},sequence.length*1000+750);          playtimeout(sequence[i]);          console.log(sequence);      } 

problem: i'm doing simon's game, , when computer shows sequence, animation twice (_bubies.clicked()). happens when sequence.length @ least 2, , animtes twice regardless how long sequence is.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -