Medium
This question is a daily question and will count towards your daily streak.
You are given an array of objects representing products in an e-commerce store. Each object contains the properties name, price, and discount. Write a function to calculate the final total cost of all the products after applying their respective discounts.
1const products = [2 { name: "Laptop", price: 1200, discount: 0.1 },3 { name: "Phone", price: 800, discount: 0.15 },4 { name: "Tablet", price: 600, discount: 0.05 },5 { name: "Headphones", price: 200, discount: 0.2 },6];