Presidents

Objectives

  • Create Constructor Functions
  • Add methods to a constructor function
  • Create objects from constructor function

Instructions

We're tutoring a high school student in US History, and they have to memorize all the presidents of the United States, and relevant information. You want to make studying fun, so you plan to build a little app to help quiz them. For now, we're just going to build out the database.

In js/script.js, build a president constructor function with following attributes: name, politicalParty, yearsInOffice, and homeState.

Add following methods to the prototype:

  • veto - returns "NO!"

  • passBill - returns "You can do that!"

  • doCharity - returns "I like to help people."

  • conductPressInterview - returns "I am proud to be an American."

  • sayHi - returns "Hi, my name is . I am from . I represent the s, and was in office .

Then create the following presidents: George Washington, Abraham Lincoln, Richard Nixon, and Jimmy Carter.

View Object Methods in JS Lab on Learn.co and start learning to code for free.