-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2_hof_params_2.js
More file actions
39 lines (33 loc) · 1.07 KB
/
2_hof_params_2.js
File metadata and controls
39 lines (33 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function saveSumOfFemaleAccounts() {
// Load Data
let persons = loadAccounts();
// Filter only female
let femalePersons = [];
for(let i=0; i < persons.length; i++) {
if(persons[i].gender == 'f') {
femalePersons.push(persons[i]);
}
}
// Double Balance
for(let i=0; i < femalePersons.length; i++) {
femalePersons[i].accountBalance *= 2;
}
// Calculate sum of the account balances
var sum = 0;
for(let i=0; i < femalePersons.length; i++) {
sum += femalePersons[i].accountBalance;
}
// Store the result
console.log(sum);
}
function loadAccounts() {
return [
{name: 'Alice', gender: 'f', birthYear: 1980, accountBalance: 1000},
{name: 'Bob', gender: 'm', birthYear: 1982, accountBalance: 1500},
{name: 'Carolina', gender: 'f', birthYear: 1986, accountBalance: 2000},
{name: 'Daniel', gender: 'm', birthYear: 1989, accountBalance: 2500},
{name: 'Epiphone', gender: 'f', birthYear: 1993, accountBalance: 3000},
{name: 'Frank', gender: 'm', birthYear: 1995, accountBalance: 3500}
];
}
saveSumOfFemaleAccounts();