I have the following javascript object
const reizen = {
personen: [
{
naam: "Bob",
reizen: [
{
locatie: "Frankrijk",
uitgaven: [
{ voorwerp: "Sokken", prijs: 15 },
{ voorwerp: "Sleutelhanger", prijs: 6 },
{ voorwerp: "Restaurant", prijs: 26 },
]
},
{
locatie: "Duitsland",
uitgaven: [
{ voorwerp: "Taxi", prijs: 30 },
]
}
]
},
]
}
I'm trying to get the sum of all values where it says 'prijs' (it's in dutch) Is there an 'easy' way to do this?
EDIT: Thanks everyone for the amazing replies! I got it to work thanks to you guys.