Advertisement
Neri0817

03. City Taxes

May 25th, 2022
727
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function cityTaxes(name, population, treasury) {
  2.   let cityInfo = {};
  3.   cityInfo.name = name;
  4.   cityInfo.population = population;
  5.   cityInfo.treasury = treasury;
  6.   cityInfo.taxRate = 10;
  7.   cityInfo.collectTaxes = collectTaxes = () =>
  8.     (cityInfo.treasury += cityInfo.population * cityInfo.taxRate);
  9.   cityInfo.applyGrowth = applyGrowth = (percentage) =>
  10.     (cityInfo.population += Math.floor(cityInfo.population * percentage) / 100);
  11.   cityInfo.applyPopulation = applyPopulation = (percentage) =>
  12.     (cityInfo.treasury -= Math.floor(cityInfo.population * percentage));
  13.  
  14.   return cityInfo;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement