Exercise Sunday

Goal: The goal of this multi-day project is to exercise your JavaScript programming skills with constructors, prototypes, objects, properties, methods, jQuery and DOM manipulation and traversal.

Warm Up

First, carefully read each project description below, and decide which project to tackle with your partner. Then, group up with other pairs working on this project for a collective, student-led brainstorming session. Map out a basic approach, collaborate, and get creative!

  • What will happen when a user clicks "Play"?
  • What objects will you need?
  • What key-value pairs will each object need to contain in order for the game to work?
  • What functions?
  • How will these be triggered throughout the gameplay?
  • How will information be collected from the user? How will it be displayed?
  • When you have a broad overview of how you want to build your game, identify the simplest behavior, and perhaps what behaviors to tackle after that. Remember to start simple and work one step at a time.


Write a program where two users can play Pig dice against each other. Don't forget to write plain English specifications with example inputs and outputs before you begin coding!

Further Exploration

  • Add options to play one of the other variations of Pig Dice using two or more dice
  • Add option to play the computer - easy or hard levels:
    • Easy: Computer always stops after second roll.
    • Hard: Computer uses strategy based on current total and rolled dice.

Tic Tac Toe (Difficult)

Note that this project is extra challenging; only begin with this if both you and your partner are fully on board. Or, consider tackling Tic Tac Toe if you finish Pig Dice with time to spare.

Create a Tic Tac Toe game for two players. Don't forget to write plain English specifications with example inputs and outputs before you begin coding!


Consider making four constructors/prototypes: Player, Space, Board, and Game. The objects created from these could include some of the following features:

  • A player should know whether it's an X or an O and be able to report that (e.g. player.mark() could return "X" or "O").
  • A space should know its coordinates and be able to be marked by a player (e.g., space.mark(player_X)).
  • A space should be able to report who it's marked by (e.g. space.markedby() could return "X" or "O", or it could return a player object - _player1 or player2).
  • A board should create 9 spaces with the proper coordinates, and tell if there are three in a row marked by the same player. A board should be able to return a space by its coordinates (e.g., board.find(1, 2)).
  • A game should create 2 players and a board, be able to move to the next turn, know which player's turn it is, and be able to tell if the game is over or not.


let testPlayer = new Player("X");
testPlayer.mark(); // returns "X"

let board = new Board();
let testSpace = board.find(1, 2); // board.find(1,2) returns a Space object

testSpace.xCoordinate(); // returns 1
testSpace.yCoordinate(); // returns 2

testSpace.markedBy(); // returns testPlayer or "X"

board.gameOver(); // returns a boolean

Further Exploration

Give users the option to play the computer at one of two levels: easy or hard.

  • Easy: Computer randomly selects squares.
  • Hard: Computer uses strategy (see strategy section in Tic Tac Toe).

Peer Code Review

  • Does the application function as expected?
  • Is the code well-refactored and easy to follow?
  • Do objects drive business logic (in JavaScript, not jQuery)?
  • Are constructors and prototypes used successfully.
  • Are plain English specs present in the README?

Lesson 1 of 11
Last updated October 21, 2021