Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factory pattern code example bug removal #227

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

omamazainab
Copy link

Expected Behaviour

Since the default values were set for the factory method i.e, Car constructor, if user did not pass any arguments at all i.e,

var carFactory = new VehicleFactory();
var car = carFactory.createVehicle();

it should create a Car object with default values. which would result in this object

Car { doors: 6, state: 'brand new', color: 'yellow' }

but instead it throws an error because if nothing is passed options will be undefined.

Correction

we set the default value of options to an empty object. It will then allow assigning all of the default values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants