Goal: add all the amount property from the transactions object:

Total = 419.98

 Source: /g/xampp8/htdocs/vuejs/vue-expense-tracker/src/App.vue

const transactions = ref([
  { id: 1, text: "Flower", amount: -19.99 },
  { id: 2, text: "Salary", amount: 299.97 },
  { id: 3, text: "Book", amount: -10 },
  { id: 4, text: "Camera", amount: 150 },
]);
 

 

// computed use to get the total from an object
const total = computed(()=>{
  return transactions.value.reduce( (acc,transaction)=>{
    return acc + transaction.amount;
  }, 0)
});