Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 8th, 2012  |  syntax: None  |  size: 0.65 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Using temporary variables in a for loop
  2. this.shuffle = function () {
  3.     ...
  4.        
  5. this.leftHalf = this.cards.slice(0, this.size() / 2);
  6.     this.rightHalf = this.cards.slice(this.size() / 2);
  7.     this.result = [];
  8.        
  9. for (var i = ...) {
  10.         this.result.unshift(this.leftHalf[i]);
  11.         this.result.unshift(this.rightHalf[i]);
  12.     }
  13.        
  14. this.cards = this.result;
  15.  
  16.     delete this.leftHalf;
  17.     delete this.rightHalf;
  18.     delete this.result;
  19. }
  20.        
  21. var leftHalf, rightHalf, result;
  22.  
  23. this.shuffle = function () {
  24.     leftHalf = ...
  25.        
  26. for(var i=...) {
  27.    if(i%2 == 1)
  28.       newdeck[i] = oldeck[N/2+(i-1)/2];
  29.    if(i%2 == 0)
  30.       newdeck[i] = oldeck[i/2];
  31. }