-
Notifications
You must be signed in to change notification settings - Fork 189
/
Copy patharray-methods.js
120 lines (103 loc) · 3.05 KB
/
array-methods.js
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
var dataset = require('./dataset.json');
/*
create an array with accounts from bankBalances that are
greater than 100000
assign the resulting new array to `hundredThousandairs`
*/
var hundredThousandairs = null;
// set sumOfBankBalances to be the sum of all value held at `amount` for each bank object
var sumOfBankBalances = null;
/*
from each of the following states:
Wisconsin
Illinois
Wyoming
Ohio
Georgia
Delaware
take each `amount` and calculate 18.9% interest for that `amount` and round to the nearest cent
and then sum up all the interest calculations into one value and save that to `sumOfInterests`
*/
var sumOfInterests = null;
/*
aggregate the sum of bankBalance amounts
grouped by state
set stateSums to be a hash table where
the key is:
the two letter state abbreviation
and the value is:
the sum of all amounts from that state
the value must be rounded to the nearest dollar
note: During your summation (
if at any point durig your calculation where the number looks like `2486552.9779399997`
round this number to the nearest dollar before moving on.
)
*/
var stateSums = null;
/*
for all states *NOT* in the following states:
Wisconsin
Illinois
Wyoming
Ohio
Georgia
Delaware
sum the amount for each state (stateSum)
take each `stateSum` and calculate 18.9% interest for that state
sum the interest values that are greater than 50,000 and save it to `sumOfHighInterests`
note: During your summation (
if at any point durig your calculation where the number looks like `2486552.9779399997`
round this number to the nearest dollar before moving on.
)
*/
var sumOfHighInterests = null;
/*
set `lowerSumStates` to be an array of two letter state
abbreviations of each state where the sum of amounts
in the state is less than 1,000,000
*/
var lowerSumStates = null;
/*
aggregate the sum of each state into one hash table
`higherStateSums` should be the sum of all states with totals greater than 1,000,000
*/
var higherStateSums = null;
/*
from each of the following states:
Wisconsin
Illinois
Wyoming
Ohio
Georgia
Delaware
Check if all of these states have a sum of account values
greater than 2,550,000
if true set `areStatesInHigherStateSum` to `true`
otherwise set it to `false`
*/
var areStatesInHigherStateSum = null;
/*
Stretch Goal && Final Boss
set `anyStatesInHigherStateSum` to be `true` if
any of these states:
Wisconsin
Illinois
Wyoming
Ohio
Georgia
Delaware
have a sum of account values greater than 2,550,000
otherwise set it to be `false`
*/
var anyStatesInHigherStateSum = null;
module.exports = {
hundredThousandairs : hundredThousandairs,
sumOfBankBalances : sumOfBankBalances,
sumOfInterests : sumOfInterests,
sumOfHighInterests : sumOfHighInterests,
stateSums : stateSums,
lowerSumStates : lowerSumStates,
higherStateSums : higherStateSums,
areStatesInHigherStateSum : areStatesInHigherStateSum,
anyStatesInHigherStateSum : anyStatesInHigherStateSum
};