Build a Node.js module that is designed to track inventory for a store. Build A Node.js module called inventory.js that exposes the following functionality: addItem
Build a Node.js module that is designed to track inventory for a store.
Build A Node.js module called inventory.js that exposes the following functionality:
addItem - A function that takes 2 parameters: an items name and price and tracks it internally.
items - A function that returns a list of items, sorted by price from least expensive to most expensive.
getMostExpensive - Returns an object that contains the items name and price for the most expensive item that has been added.
getLeastExpensive - Returns an object that contains the items name and price for the most least expensive item that has been added.
removeItem - Remove an item by name.
getItemByName - Returns an items name and price by name.
getItemByPrice - Returns an items name and price by price.
Your module should not expose any functions or variables that would allow the above functions to have the integrity of their data compromised.
NOTES:
* Cannot use any third party JavaScript libraries
* Must use JavaScripts strict mode
* Must use let instead of var
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started