Question: Create a Function to Place an Order Write a function named placeOrder that accepts the customer name and an array of ordered items. The function
Create a Function to Place an Order
Write a function named placeOrder that accepts the customer name and an array of ordered items. The function should:
Check if there are enough products in stock for each item in the order. If any item has insufficient stock, log an error message and do not place the order.
If all items are available, subtract the ordered quantity from the products stock in the inventory array.
Add a new order to the orders array with the status set to "Pending".
Commit: "Create placeOrder function"
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
