/ Published in: JavaScript
Given my base pay and an optional pre-tax 401k contribution percentage, calculate my net pay. Assumes US income tax of 27%. All results will be approximate (the browser is not a reliable calculator)!
Expand |
Embed | Plain Text
function paycheck (paid, retirementPercent) { var retireContrib = paid * retirementPercent * .01; paid = paid - retireContrib; var taxes = (paid * .27); var paycheck = paid - taxes; //taxes take 27 percent var totalOut = retireContrib + taxes; return retirementPercent+" 401k contribution:"+ "\nNet Paycheck: ~$"+paycheck+ "\n401k contrib: ~$"+retireContrib+ "\ntaxes paid: ~$"+taxes+ "\nTotal Out: ~$"+totalOut; } //8% retirement contribution from a $1234 paycheck: paycheck (1234, 8);
You need to login to post a comment.
