Created
January 6, 2020 22:58
-
-
Save BetterProgramming/57b0b73cef289880d34ff95de384f00b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
export default function Totals({ priceArr, freqInDays, amountToInvest }) { | |
const numOfDays = priceArr.length; | |
let coinAmount = 0; | |
for (let i = 0; i < numOfDays; i += freqInDays) { | |
const coinValue = priceArr[i][1]; | |
coinAmount += amountToInvest / coinValue; | |
} | |
const totalCoinAmount = coinAmount; | |
const totalInvested = amountToInvest * Math.floor(numOfDays / freqInDays); | |
const endTotal = totalCoinAmount * priceArr[priceArr.length - 1][1]; | |
const numberGained = endTotal - totalInvested; | |
const percentGained = ((endTotal - totalInvested) / totalInvested) * 100; | |
return <div>Totals</div>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment