I want to get the size of each food in the menu and add the size of all of them together and display the total size of the menu in the console. Please help. My code does not work.
The desired result => total size : 225
let menu = [
{ id: 1, name: "Soda", price: 3.12, size: "4oz", type: "Drink" },
{ id: 2, name: "Beer", price: 6.50, size: "8oz", type: "Drink" },
{ id: 3, name: "Margarita", price: 12.99, size: "12oz", type: "Drink" },
{ id: 4, name: "Pizza", price: 25.10, size: "60oz", type: "Food" },
{ id: 5, name: "Kebab", price: 31.48, size: "42oz", type: "Food" },
{ id: 6, name: "Berger", price: 23.83, size: "99oz", type: "Food" },
];
const totalSize = () => {
const b = parseFloat(menu.size);
const result = b.forEach(itemA, itemB => itemA + itemB);
console.log(`total size : ${result}`)
}
totalSize();