Skip to content

Commit

Permalink
Merge pull request #26 from lkdm/main
Browse files Browse the repository at this point in the history
New version
  • Loading branch information
lkdm authored Aug 31, 2021
2 parents c842b71 + 87b1a1f commit 4a1fd5f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import ResultsText from './components/result/ResultsText'

const defaultStrategy: Strategy = {
initialDeposit: 0, // in cents
regularDeposit: 0, // in cents
depositFrequency: "Monthly",
compoundFrequency: "Monthly",
regularDeposit: 2000, // in cents
depositFrequency: "Annually",
compoundFrequency: "Annually",
numberOfYears: 10,
annualInterestRate: 5
annualInterestRate: 500
}

const App = () => {
Expand Down Expand Up @@ -83,14 +83,14 @@ const App = () => {
<div className="row justify-content-center">
<div className="col-12">
<h2>Results</h2>
<ResultChart data={result} initialDeposit={strategy.initialDeposit} />
{(strategy.numberOfYears > 0) ? <ResultChart data={result} initialDeposit={strategy.initialDeposit} /> : "" }
</div>
</div>

<div className="row justify-content-center">
<div className="col-12">
<h3>Your strategy</h3>
<ResultsText data={result} initialDeposit={strategy.initialDeposit} />
{(strategy.numberOfYears > 0) ? <ResultsText data={result} initialDeposit={strategy.initialDeposit} /> : "" }
</div>
</div>
<hr />
Expand Down
3 changes: 3 additions & 0 deletions src/services/CompoundInterest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ const frequencyPerYear = (frequency: Frequency): number => {

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

// Guard: Check number of years is more than 0
if (strategy.numberOfYears < 1) return

// Definitions
const initialDeposit = strategy.initialDeposit/100
const regularDeposit = strategy.regularDeposit/100
Expand Down

0 comments on commit 4a1fd5f

Please sign in to comment.