JSFiddle - React, Tailwind, and code Playground
by Trevor W
HTML
<table>
<tr>
<th>Month</th>
<th>Total Revenue</th>
<th>Monthly Revenue</th>
<th>MRR</th>
</tr>
</table>
JavaScript
let monthlyFee = 5;
let conversionRate = 0.10;
let keywordVol = 74000;
let clickRate = 0.80;
let newMonInc = ((keywordVol * clickRate) * conversionRate) * monthlyFee;
let month1Churn = 1 - 0.5;
let month2Churn = 1 - 0.25;
let month3Churn = 1 - 0.2;
let month4to8Churn = 1 - 0.15; // Adjusted to month 4 to 8
let month9to17Churn = 1 - 0.1; // Adjusted to month 9 to 17
let month18to48Churn = 1 - 0.05;
function formatUSD(number) {
return new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
}).format(number);
}
let totalRevenue = 0;
let currentRevenue = newMonInc; // Start with the initial month's revenue
for (var i = 1; i <= 48; i++) {
if (i === 1) {
currentRevenue *= month1Churn;
} else if (i === 2) {
currentRevenue *= month2Churn;
} else if (i === 3) {
currentRevenue *= month3Churn;
} else if (i >= 4 && i <= 8) { // Corrected the range
currentRevenue *= month4to8Churn;
} else if (i >= 9 && i <= 17) { // Corrected the range
currentRevenue *= month9to17Churn;
} else if (i >= 18) {
currentRevenue *= month18to48Churn;
}
let revenue = newMonInc + currentRevenue; // Add new income to the remaining revenue
totalRevenue += revenue;
let row = "<tr>";
row += "<td>" + i + "</td>";
row += "<td>" + formatUSD(totalRevenue) + "</td>";
row += "<td>" + formatUSD(revenue) + "</td>";
row += "<td>" + formatUSD(currentRevenue) + "</td>";
row += "</tr>";
$("table").append(row);
currentRevenue += newMonInc; // Update the current revenue for the next month
}