Child
Since we already have built a Parent object, let's look at giving them a child.
Completed Code
function Child(firstName, lastName, gender, age, birthday, grade, interests) {
    Person.call(this, firstName, lastName, gender, age, birthday);
    this.grade = grade;
    this.interests = interests;
}
Child.prototype = Object.create(Person.prototype);
Child.prototype.constructor = Child;
Child.prototype.intro = function () {
    return (this.fullName() + ' is a/an ' + this.age + "-year-old " + this.ordinalSuffix(this.grade) + " grader.");
};
Child.prototype.enjoy = function () {
    if (this.pronoun().toLowerCase() == "he" || this.pronoun().toLowerCase() == "she") {
        return (this.firstName + "'s birthday is " + this.birthday + " and " + this.pronoun().toLowerCase() + " enjoys " + this.interests + ".");
    } else {
        return (this.firstName + "'s birthday is " + this.birthday + " and " + this.pronoun().toLowerCase() + " enjoy " + this.interests + ".");
    }
};    
var child1 = new Child ('Bon', 'Jovi', 'male', 6, 'March 2', 1, 'singing and dancing');
console.log(child1);
console.log(child1.intro());
console.log(child1.enjoy());Output
Child {
  firstName: 'Bon',
  lastName: 'Jovi',
  gender: 'male',
  age: 6,
  birthday: 'March 2',
  nextYear: 7,
  fullName: [Function],
  pronoun: [Function],
  possessive: [Function],
  ordinalSuffix: [Function],
  grade: 1,
  interests: 'singing and dancing' }
Bon Jovi is a/an 6-year-old 1st grader.
Bon's birthday is March 2 and he enjoys singing and dancing.Explanation
We know the general structure from our Parent object, so let's see what we added. 1. New properties
- grade- the child's grade in school
- interests- the child's interests- New functions/methods 
 
- intro()- Displays- fullName(),- age, and- gradewith- ordinalSuffix()added for proper grammar.
- enjoy()- Displays- firstName,- birthday,- pronoun(), and- interests.
Last updated
