JS Requirement 1
JS Requirement 1
1. Initialize Data:
2. Functionality:
• Remove Duplicates:
Use a Set to remove duplicate entries from the book list based on the
book’s id.
• Prepare Bill:
❖ Book titles.
❖ Quantity.
❖ Individual prices before and after discount.
❖ Total price.
❖ Discount applied.
• Update Stock:
Reduce the stock count for each book purchased.
3. Technical Requirements:
• Use map and filter for processing arrays.
4. Output:
The function should return:
5. Sample Execution:
Input:
Output:
{
bill: {
customerName: 'John Doe',
booksPurchased: [
{ title: 'Book A', quantity: 1, price: 300, discount: 45, finalPrice: 255 },
{ title: 'Book B', quantity: 1, price: 150, discount: 3, finalPrice: 147 }
],
totalPrice: 402,
totalDiscount: 48,
},
}
updatedStock: [...],
updatedCustomerDetails: { ... },