Skip to content

Commit 6e176de

Browse files
committed
commit
1 parent f96cdb0 commit 6e176de

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

11-Arrays-Bankist/starter/script.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const account4 = {
3535

3636
const account5 = {
3737
owner: 'Genildo Cerqueira Souza',
38-
movements: [50, 350, 1700, 1150, 19090],
38+
movements: [50, 350, 1700, 1150, 19090, -5000, -80, -2500, 1690],
3939
interestRate: 3,
4040
pin: 5555,
4141
};
@@ -78,7 +78,7 @@ const displayMoviments = function(moviments){
7878
<div class="movements__row">
7979
<div class="movements__type movements__type--${type}">${i + 1} ${type}</div>
8080
81-
<div class="movements__value">${mov}</div>
81+
<div class="movements__value">R$ ${mov}</div>
8282
</div>
8383
`
8484
containerMovements.insertAdjacentHTML("afterbegin", html)
@@ -94,6 +94,20 @@ const calcDisplayBalance = function(movements){
9494
}
9595
calcDisplayBalance(account5.movements)
9696

97+
const calcDisplaySummary = function(movements){
98+
const incomes = movements.
99+
filter(mov => mov > 0).
100+
reduce((acc, mov) => acc + mov, 0);
101+
labelSumIn.textContent = `R$ ${incomes}`;
102+
103+
const outcomes = movements.
104+
filter(mov => mov < 0).
105+
reduce((acc, mov)=> acc + mov, 0);
106+
labelSumOut.textContent = `R$ ${Math.abs(outcomes)}`
107+
}
108+
109+
calcDisplaySummary(account5.movements);
110+
97111
const createUserNames = function(accs){
98112
accs.forEach((acc)=>{
99113
acc.username = acc.owner

0 commit comments

Comments
 (0)