According to what you did, you can do this to get price from product and quantity from basketItem without declaring variables on two separate lines.
const calculateTotal = (items) => { return items.reduce((totalPrice, basketItem) => { const { product: { price }, quantity } = basketItem; const total = price * quantity; return totalPrice + total; }, 0); };
source share