How to use for each on array of object?

So i wanna get the total of each object, but I only get undifined with this for each method.
what could go wrong?

var product = [
  {"name":"Pie Susu","price":12000,"quantity":1},
  {"name":"Kacang Bali","price":5000,"quantity":2},
  {"name":"Pie Apel Susu","price":15000,"quantity":2}

the price * quantity but i got undefined when use foreach.
what i tried.

var total = product.forEach( value => value.price * value.quantity);

Solved using map

var total = => {
  return cartArr.price * cartArr.quantity
}).reduce((a, b) => a + b, 0)

any feedback on how to use forEach please write

forEach does not have a return value, so it will probably assign the value undefined to forEach. If you want to use forEach, then you would write:

var total = 0;
product.forEach( value => {
  total += value.price * value.quantity

Oh nice. :grinning: dont know about that thanks