Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
Last active July 22, 2022 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McLarenCollege/4e1d7d3a96ca923c454883cecf25dae2 to your computer and use it in GitHub Desktop.
Save McLarenCollege/4e1d7d3a96ca923c454883cecf25dae2 to your computer and use it in GitHub Desktop.
Tax Percentage

Given the income of a person and whether he or she has children, calculate the tax percentage based on the following rules:

  • If income is above 50,000 the tax is 45% otherwise 40%
  • If there are children then the tax percentage decreases by 2%.

For example,

  • If a person with children has an income of 60,000 then the tax is 43%
  • If a person without children has an income of 20,000 then the tax is 40%
  • If a person with children has an income of 15,000 then the tax is 38%
let income = 60000;
let hasChildren = true;
let taxPercentage;

// write your code here

console.log("The applicable tax percentage is " + taxPercentage + "%");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment