Published
Edited
Sep 19, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
const price = 50.0;
const counts = 2000;
const target = 125;

const percents = [18, 18, 18, 15, 15, 15, 10, 10, 10, 8, 8, 8, 6, 6];
let bonus = 1.253;
let total = 0.0;

const years = percents.length;

let md = "";
let dynamic = price;
for (let i = 0; i < years; i++) {
bonus = (1 + percents[i] / 100.0) * bonus;
dynamic -= bonus;
total += bonus;
let earning = (target + bonus) / dynamic - 1;
md += `- ${i + 1}: Bonus: ${bonus.toFixed(3)} - Price: ${dynamic.toFixed(
3
)} - Earning: ${earning.toFixed(3)}\n`;
}

md += `- Bonus Total: ${(total / price).toFixed(3)}\n`;

mutable Output = md;

return "Succeed";
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more