Category
Percentage
Federal taxes
31%
State taxes
8%
Local taxes
2%
All local taxes are deductable from the gross amount used to calculate state taxes. Likewise all state and local taxes are deductable from the gross amount used to calculate federal taxes. The function should accept one parameter the gross pay and return one result the total withholdings based on the above table and rules. Again the function should not do any output but should just return a number. Here is an example:
Input: 1000.00 return 377.90. Why not just 41% of 1000 = 410? 2% of $1000.00 is $20.00. Now subtract the $20.00 out of the gross leaving $980.00 as the base for calculating state taxes. 8% of $980.00 is $78.40. Subtract $78.40 from the $980.00 to get $901.60 the base for calculating federal taxes. 31% of $901.60 is $279.50 (rounded to the nearest penny). When $20.00 $78.40 and $279.50 are added together the result is $377.90 which is the answer that should be returned from the function. Note that these numbers are rounded to the nearest penny which is possible with either the .toFixed() method of a number or by using Math.round().
I attached the homework file