Changed around line 1
+ document.addEventListener('DOMContentLoaded', function() {
+ const currentAge = document.getElementById('currentAge');
+ const retirementAge = document.getElementById('retirementAge');
+ const monthlySavings = document.getElementById('monthlySavings');
+ const bitcoinAllocation = document.getElementById('bitcoinAllocation');
+ const allocationValue = document.getElementById('allocationValue');
+ const bitcoinGrowth = document.getElementById('bitcoinGrowth');
+ const inflation = document.getElementById('inflation');
+ const calculateButton = document.getElementById('calculate');
+
+ const totalSavings = document.getElementById('totalSavings');
+ const bitcoinHoldings = document.getElementById('bitcoinHoldings');
+ const retirementIncome = document.getElementById('retirementIncome');
+
+ bitcoinAllocation.addEventListener('input', function() {
+ allocationValue.textContent = `${this.value}%`;
+ });
+
+ calculateButton.addEventListener('click', function() {
+ const yearsToRetirement = retirementAge.value - currentAge.value;
+ const totalMonths = yearsToRetirement * 12;
+ const bitcoinPercent = bitcoinAllocation.value / 100;
+ const traditionalPercent = 1 - bitcoinPercent;
+
+ // Traditional savings calculation
+ const traditionalFutureValue = monthlySavings.value * traditionalPercent *
+ (((Math.pow(1 + (inflation.value/100), yearsToRetirement) - 1) / (inflation.value/100)));
+
+ // Bitcoin savings calculation
+ const bitcoinFutureValue = monthlySavings.value * bitcoinPercent *
+ (((Math.pow(1 + (bitcoinGrowth.value/100), yearsToRetirement) - 1) / (bitcoinGrowth.value/100)));
+
+ const totalFutureValue = traditionalFutureValue + bitcoinFutureValue;
+
+ // Display results
+ totalSavings.textContent = `$${Math.round(totalFutureValue).toLocaleString()}`;
+ bitcoinHoldings.textContent = `${Math.round(bitcoinFutureValue / 50000)} BTC`; // Assuming $50,000 per BTC
+ retirementIncome.textContent = `$${Math.round(totalFutureValue * 0.04).toLocaleString()}/year`; // 4% rule
+ });
+ });