I'm working with the following code snippet:
const my_transactions = [{amount: -100,currency: 'EUR'},{amount: -200,currency: 'EUR'},{amount: -400,currency: 'EUR'}];
let total = 0;
my_transactions.forEach(el => total = total - el.amount);
console.log('total:',total);
All the amounts are negative in this code. The goal is to sum all the amounts and display the overall balance. In this scenario, the balance is negative. The expected output should be
-700
However, the variable "total" ends up with a positive value instead. What could be causing this unexpected behavior?