completes javascript to finish game. includes main gameplay and accounts for ties.  has some testing code included.