File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -10,11 +10,11 @@ import ResultsText from './components/result/ResultsText'
10
10
11
11
const defaultStrategy : Strategy = {
12
12
initialDeposit : 0 , // in cents
13
- regularDeposit : 0 , // in cents
14
- depositFrequency : "Monthly " ,
15
- compoundFrequency : "Monthly " ,
13
+ regularDeposit : 2000 , // in cents
14
+ depositFrequency : "Annually " ,
15
+ compoundFrequency : "Annually " ,
16
16
numberOfYears : 10 ,
17
- annualInterestRate : 5
17
+ annualInterestRate : 500
18
18
}
19
19
20
20
const App = ( ) => {
@@ -83,14 +83,14 @@ const App = () => {
83
83
< div className = "row justify-content-center" >
84
84
< div className = "col-12" >
85
85
< h2 > Results</ h2 >
86
- < ResultChart data = { result } initialDeposit = { strategy . initialDeposit } />
86
+ { ( strategy . numberOfYears > 0 ) ? < ResultChart data = { result } initialDeposit = { strategy . initialDeposit } /> : "" }
87
87
</ div >
88
88
</ div >
89
89
90
90
< div className = "row justify-content-center" >
91
91
< div className = "col-12" >
92
92
< h3 > Your strategy</ h3 >
93
- < ResultsText data = { result } initialDeposit = { strategy . initialDeposit } />
93
+ { ( strategy . numberOfYears > 0 ) ? < ResultsText data = { result } initialDeposit = { strategy . initialDeposit } /> : "" }
94
94
</ div >
95
95
</ div >
96
96
< hr />
Original file line number Diff line number Diff line change @@ -36,6 +36,9 @@ const frequencyPerYear = (frequency: Frequency): number => {
36
36
37
37
export const calculateCompoundInterest = ( strategy : Strategy ) => {
38
38
39
+ // Guard: Check number of years is more than 0
40
+ if ( strategy . numberOfYears < 1 ) return
41
+
39
42
// Definitions
40
43
const initialDeposit = strategy . initialDeposit / 100
41
44
const regularDeposit = strategy . regularDeposit / 100
You can’t perform that action at this time.
0 commit comments