- Create constructor functions
- Add methods to a constructor function
- Create objects from a constructor function
We're tutoring a high school student in U.S. History, and they have to memorize all the U.S. presidents (and relevant information). We want to make studying fun, so the plan is to build a little app to help quiz them. For now, we're just going to build out the database.
In index.js
, build an ES6 President
class with the following properties set by the constructor: name
, politicalParty
, yearsInOffice
, and homeState
.
Add following methods to the class:
-
veto
— returnsNO!
-
passBill
— returnsYou can do that!
-
doCharity
— returnsI like to help people.
-
conductPressInterview
— returnsI am proud to be an American.
-
sayHi
— returnsHi, my name is <name>. I am from <homestate>. I represent the <politcalParty>s, and was in office <yearsInOffice>.
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.