Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Node.js module, employeeModule_v1.js, with the following functionality. The module maintains an array of JavaScript objects, each with the property firstName, lastName, and a

Write a Node.js module, employeeModule_v1.js, with the following functionality. The module maintains an array of JavaScript objects, each with the property firstName, lastName, and a unique id value. For example, a sample initial data is shown below.

image text in transcribed The module should export the functions lookupById, lookupByLastName, and addEmployee. The function lookupById should return the JavaScript object from the data whose id matches the specified argument. If the specified id is not present, undefined is returned. The function lookupByLastName should return the array of JavaScript objects from the data whose lastName matches the specified argument. If the specified lastName is not present, [] is returned. The function addEmployee only takes two arguments, the firstName and lastName of the employee being added. The id value should be calculated as one more than the current maximum id. Write the code for the module using only JavaScript and without using the underscore module. Now, write the application, hw1a.js, using the functionality of the above module. Write the code to do the following: Lookup by last name, Smith, and print the results. Add a new employee with first name, William, and last name, Smith. Lookup by last name, Smith, and print the results. Lookup by id, 2, and assign the value to a variable. Print the variable. Using the above variable, change the first name to Mary. Lookup again by id, 2, and print the result. Lookup by last name, Smith, and print the results. The sample output of the application is shown below. You can optionally use the colors module for colors in the output.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions

Question

10-9 How have social technologies changed e-commerce?

Answered: 1 week ago