I have an array of bank accounts, which I receive from a GET request.
<div class="card" *ngFor="let acc of accounts">{{acc.iban}} ({{acc.currency}})>
Accounts array is for example like that:
this.accounts = [
{ iban : '123' , currency: 'EUR' },
{ iban: '123' , currency: 'USD' },
{ iban: '234' , currency: 'EUR' }
]
How can I dynamically find accounts with the same iban, remove one of them from the list, and add removed the account's currency to the other account ?
The expected output is:
this.accounts = [
{ iban: '123' , currency 'EUR, USD' },
{ iban: '234' , currency: 'EUR' }
]