about summary refs log tree commit diff stats
path: root/js/freelance.js
blob: 533fa98d96c5d923b3ea2a624ecddec339a45561 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// can I go freelance?
// doing some math to see if I can afford to go freelance, or what it'd take to do it

// r is hourly rate
// h is hours per week
// w is weeks per year
// ws is weeks of savings
// returns object with income, savings, and tax where income is after tax and savings are subtracted

const a = (r, h, w, ws) => {
  let income = (r * h) * w;
  const tax = income * 0.16; // as of 2024 actual tax rate is more like 15.3%, but I'm rounding to 16%
  income -= tax;
  const savings = ws * w;
  income -= savings;
  return {
    income: income,
    savings: savings,
    tax: tax,
  };
};

const m = a(125, 24, 48, 300); // $125/hr, 24 hours/week, 48 weeks/year, saving $300 a week
console.log(
  `annual income: $${m.income}, annual savings: $${m.savings}, annual tax: $${m.tax}`,
);

const n = a(100, 30, 48, 300); // $100/hr, 30 hours/week, 48 weeks/year, saving $300 a week
console.log(
  `annual income: $${n.income}, annual savings: $${n.savings}, annual tax: $${n.tax}`,
);

const o = a(75, 30, 48, 300); // $75/hr, 40 hours/week, 48 weeks/year, saving $300 a week
console.log(
  `annual income: $${o.income}, annual savings: $${o.savings}, annual tax: $${o.tax}`,
);