Exercise Sunday

Goal: Practice creating objects in JavaScript using constructors and prototypes. Use test-driven development to create your business logic. There should be tests for all functionality in your business logic, and they should be included in your project's README.

Warm Up


  • What is the difference between creating an object using literal notation, and creating an object using a constructor?
  • What benefits do constructors offer?
  • What is a prototype? How does it differ from a constructor?

Code


Start by building the Address Book application. Then, pick either of the remaining project prompts to complete.

Address Book

Follow along with this weekend's homework to create an address book application using constructors and prototypes.

Places You've Been

Create a website where you can keep track of all the places you've been. Each destination should be an object with multiple properties, like location, landmarks, time of year, notes, etc. Display those properties when a user clicks on a place's name. Complete the business logic for your place object. Use test-driven development to write your business logic, and include the tests in your README.md. After every passing test, make sure to commit your code.

If you complete the business logic, you may work on adding a user interface. (See the upcoming lessons for more on adding a UI.)

To Do List

Make a to do list page where people can add tasks to create a list of things to do.

  • Add an option for users to indicate a task is done.
  • Allow users to remove a task from the list.
  • Use test-driven development to write your business logic, and include the tests in your README.md. After every passing test, make sure to commit your code.

If you complete the business logic, you may work on adding a user interface. (See the upcoming lessons for more on adding a UI.)

Peer Code Review


  • Do JavaScript objects drive application logic?
  • Are constructors and prototypes used successfully?
  • Are pseudo-coded tests present in the README?
  • Does the application work as expected?

Lesson 15 of 25
Last updated July 14, 2022