great question. reducer can be a very confusing method to use, but it can get very simplified if you think about it like this:
you have an array and a value you want to run an operation on all elements and get a single value (that value can be of whatever type you want).
now in order to get the value you want, you first need to flat your array of arrays to make it easier to work with, for this use the js .flat() method.
now that you have a single array that should look like so:
const flattenedArray = [
{
item: "Chocolate Waffle"
price: 5000
},
{
item: "Strawberry Waffle"
price: 6000
},
{
item: "Chocolate Waffle"
price: 5000
}
]
you can simply use the reduce method like so to get the total:
const total = flattedArray.reduce((prev, curr) => prev + curr.price, 0);