Prototypes in JS Lab

Objectives

  • Refactor code to use prototypes
  • Ensure that each method is only declared one time yet can be referenced by the newly created objects

Instructions

With our new knowledge of prototypes, we would like to refactor our previously written code to declare each function only one time. So, your task is to take our existing code and refactor it using prototypes.

In index.js, BoardMember constructor function with the following properties set by the constructor: name, training, and homeState.

Add following methods to the prototype of the constructor:

  • veto — returns No, I must disagree

  • approve — returns You can do that!

  • doCharity — returns I like to help people.

  • releasePressStatement — returns You will see great things from Scuber.

  • sayHi — returns "Hi, my name is <name>. I am from <homestate>, and I was trained in <training>.

View Prototypes Lab on Learn.co and start learning to code for free.