Skip to content

Commit 4a1fd5f

Browse files
authored
Merge pull request #26 from lkdm/main
New version
2 parents c842b71 + 87b1a1f commit 4a1fd5f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/App.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import ResultsText from './components/result/ResultsText'
1010

1111
const defaultStrategy: Strategy = {
1212
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",
1616
numberOfYears: 10,
17-
annualInterestRate: 5
17+
annualInterestRate: 500
1818
}
1919

2020
const App = () => {
@@ -83,14 +83,14 @@ const App = () => {
8383
<div className="row justify-content-center">
8484
<div className="col-12">
8585
<h2>Results</h2>
86-
<ResultChart data={result} initialDeposit={strategy.initialDeposit} />
86+
{(strategy.numberOfYears > 0) ? <ResultChart data={result} initialDeposit={strategy.initialDeposit} /> : "" }
8787
</div>
8888
</div>
8989

9090
<div className="row justify-content-center">
9191
<div className="col-12">
9292
<h3>Your strategy</h3>
93-
<ResultsText data={result} initialDeposit={strategy.initialDeposit} />
93+
{(strategy.numberOfYears > 0) ? <ResultsText data={result} initialDeposit={strategy.initialDeposit} /> : "" }
9494
</div>
9595
</div>
9696
<hr />

src/services/CompoundInterest.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ const frequencyPerYear = (frequency: Frequency): number => {
3636

3737
export const calculateCompoundInterest = (strategy: Strategy) => {
3838

39+
// Guard: Check number of years is more than 0
40+
if (strategy.numberOfYears < 1) return
41+
3942
// Definitions
4043
const initialDeposit = strategy.initialDeposit/100
4144
const regularDeposit = strategy.regularDeposit/100

0 commit comments

Comments
 (0)