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 Person object:

  • name and set is as Amy.

  • age and set it 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

Get hands-on with 1400+ tech skills courses.