Exercise 1: Who's the Teacher?

In this exercise, you have to implement prototypal inheritance between two objects, Person and Teacher.

We'll cover the following

Problem Statement

In this exercise, two object literals, Person and Teacher are given.

Define the following properties in the Teacher object:

  • name and set is as Amy.

  • age and set is as 28.

Define the following properties in the Teacher object:

  • subject and set it as Maths

  • grade and set it as 8

Next you have to set Person as the prototype of Teacher so that its properties can be accessed in Teacher.

Sample Input

The following will be accessed from the Teacher object:

name
age
subject
grade

Sample Output

Amy
28
Maths
8

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy