• Theory
  • Theory

Seventh program: “From salary to salary”

The boss liked the mile calculator and this is why he entrusted you with automating what he values the most: his accounting!

He needs to hire a few new employees, since local idlers no longer suffice. The accounting department has allocated a budget for salaries, but it includes taxes, and in job advertisements, salary should be indicated without taxes. Anyway, here is the technical assignment:

Meow! I need a program that will use the gross salary (salary before tax) to calculate an approximate take-home salary (that is given out).

Design the program as calculateSalary function with one parameter: gross salary amount. The function must return the take-home salary.

I do not need great accuracy, we just take into account that 35% of the gross salary amount are taxes, and if gross salary is greater than or equal to 100 thousand, then taxes are already 45%.

Depending on how you calculate, the final result may have a fractional part. You can use Math.round to round the calculation results.

This program will be tested by Muffin himself. He’ll call your function (you’re going to write the function, right?) with different arguments and will check the result. To call the boss to check the program, press the Hey boss, here’s your program! button located in the console.

  • index.html
HTML
HTML

You’ve gone to a different page

Click inside the mini-browser to shift the focus onto this window.

100%
Granny Muffin

Easy there, pal!

To access the Functions challenges in the JavaScript programming, you need to sign up and subscribe first.