Challenge: Solution Review
Explore how to implement the builder design pattern in JavaScript through a detailed solution review. Learn to structure classes and methods to create complex objects step-by-step, enhancing your understanding of creational patterns for coding interviews.
We'll cover the following...
We'll cover the following...
Solution #
Explanation
You were given the following code:
var assignment = new Assignment();
var assignmentBuilder = new AssignmentBuilder("Math","Hard","12th June, 2020");
var mathAssignment = assignment.make(assignmentBuilder);
mathAssignment.announcement();
You had to complete the code implementation of this program. From the first line, we know that we need to have a class Assignment that accepts no parameters. So, let’s declare that first.
The code above gives an error since some other functions/methods being used are not defined. So, let’s move on to the next line.
var assignmentBuilder = new ...