![enter image description here](https://i.stack.imgur.com/rjwSX.png)

I would like to follow the inheritance structure shown above. I would like create an engineer using this syntax:

```
var Mark = new Employee(id).WorkerBee(project).Engineer();

```

To achieve this syntax, I have to create a nested object following a parasitic inheritance pattern like so: 

```
    function Employee(id) {
      this.id = id;

      this.WorkerBee = function(project) {
        this.project = project;

        this.Engineer = function() {
          ...
          return this;
        };

        return this;
      };
    }

```

To avoid deep layers of nesting, I am trying to rewrite it using prototypes. How can I rewrite my code to achieve the same goal as above ?

```js
      function Employee(id) {
        //variables
        this.id = id
        this.name = "";
        this.dept = "general";

        //methods
        this.getId = function() {
          return this.id
        }
      }
    Employee.prototype.WorkerBee = WorkerBee;

    function WorkerBee(project) {
      //variables
      this.projectName = project
      this.projects = [];
      //methods
      this.getProjectName = function() {
        return this.projectName
      }
      return this
    }
    WorkerBee.prototype.Engineer = Engineer

    function Engineer() {
      //variables
      this.dept = "engineering";
      this.machine = "";
      //methods
      this.getDept = function() {
        return this.dept
      }
      return this
    }

    var Mark = new Employee("5").WorkerBee("Secret Project").Engineer();
    console.log(Mark.getId()) //should print "5"
    console.log(Mark.getProjectName()) //should print "Secret Project"
    console.log(Mark.getDept()) //should print engineering
```