Task: Implement a simple in-memory Address Book in /app with two classes (Contact and AddressBook) and the required API to satisfy the tests.
What to implement
Create a module app/Contact.js that exports a Contact class.
The class can be empty (no required fields) since tests only instantiate it and pass references around.
Create a module app/AddressBook.js that exports an AddressBook class with the following API and behavior:
Properties (on new AddressBook()):
contacts: an empty array to store Contact instances.
initialComplete: a boolean initialized to false.
Methods:
addContact(contact): add the given contact to the end of the contacts array.
getContact(index): return the contact at the given index, or undefined if out of bounds.
deleteContact(index): remove the contact at the given index from the contacts array (no error if index is out of bounds—test suite uses index 0 after adding one item).
getInitialContacts(callback): simulate an asynchronous operation (e.g., use setTimeout with 0 ms). When finished:
Populate this.contacts with one or more initial Contact instances (at least one is fine).
Set this.initialComplete = true.
If a callback function is provided, invoke it (i.e., callback()).
Export style: Use CommonJS module exports (module.exports) so tests that require the modules can import AddressBook and Contact.
File structure to create
/app/Contact.js
Exports the Contact class.
/app/AddressBook.js
Exports the AddressBook class with the described properties and methods.
Notes and constraints
The tests instantiate new AddressBook() and new Contact() directly, so ensure the exports allow new AddressBook() and new Contact() to work without additional wiring.
The async getInitialContacts(cb) must call the provided callback after completing initialization to satisfy the "Async Address Book" test.
The tests rely only on object identity for add/get (addressBook.getContact(0) should return the exact object added). Ensure addContact stores the reference, not a copy.
Do not modify the tests; ensure the implementation is self-contained in /app/.