CHAPTER 10
Code Explanation
housexp= 500; Resets the horizontal position for
the dealers hand
dealstart(); Calls the function to initially deal the
cards
} Closes the function
function showhouse() { Header for the function to reveal the
dealers hand
var i; For iteration
housexp= 500; Resets the horizontal position
for (i=0;i<hi;i++) { for loop over the hand
ctx.drawImage(househand[i].picture,
housexp,houseyp,cardw,cardh);
Draws the card
housexp = housexp+20; Adjusts the pointer
} Closes the for loop
} Closes the function
function shuffle() { Header for the shuffle
var i = deck.length - 1; Sets the initial value for the i
variable to point to the last card
var s; Variable used for the random choice
while (i>0) { As long as i is greater than zero
s = Math.floor(Math.random()*(i+1)); Makes a random pick
swapindeck(s,i); Swaps with the card in the i position
i--; Decrement
} Closes the while loop