How I can use the filter to populate the variable onlyAmountLess5? I want to filter only products where sales' amount < 5:
const products = [
{ id: 1, name: "bread", value: 2.0, category: "bakery", "sales":[{"day": "07/04/2021", "amount": 12}, {"day": "10/04/2021", "amount": 18}] },
{ id: 2, name: "apple", value: 6.5, category: "fruit", "sales":[{"day": "07/04/2021", "amount": 4}, {"day": "10/04/2021", "amount": 18}] },
{ id: 3, name: "pizza", value: 2.0, category: "food", "sales":[{"day": "07/04/2021", "amount": 5}, {"day": "10/04/2021", "amount": 18}]} ,
{ id: 4, name: "cheese", value: 7.0, category: "bakery", "sales":[{"day": "07/04/2021", "amount": 12}, {"day": "10/04/2021", "amount": 5}] },
{ id: 5, name: "milk", value: 2.2, category: "food", "sales":[{"day": "07/04/2021", "amount": 12}, {"dia": "10/04/2021", "amount": 3}]}
];
const onlyBakery = products.filter( p => p.category ==="bakery")
console.log(onlyBakery);
// List only product where sales amount < 5
const onlyAmountLess5 = products.filter(o => products.sales.amount < 4)
< 4is not the same as< 5