Hello,
I have been working on this for awhile trying to understand how to use functions. I am not sure what I am doing wrong, sometimes this works, sometimes it doesn’t. Is there a better way (and still a simple way) to use the function to print out all the input at once?
[CODE]
<HTML>
<HEAD>
<TITLE>SimpleFunction</TITLE>
<SCRIPT TYPE=”text/javascript”>
// Prompt user to enter information
var hoursperweek;
var payperhour;
var taxes;
var totalpay;
</SCRIPT>
</HEAD>
<BODY>
<script type=”text/javascript”>
hoursperweek=prompt(“hours you work per week: “,””);
payperhour=prompt(“Pay per hour: “,””);
taxes=prompt(“Tax rate: “,””);
document.write(“Hours Worked: “+hoursperweek);
document.write(“Hourly Payrate: “+payperhour);
document.write(“Tax rate: “+taxes);
function finalpay(hoursperweek, payperhour, taxes)
{
return var totalpay = (hoursperweek * payperhour) – taxes;
}
document.write(“Net Pay= “+finalpay);
</script>
</BODY>
</HTML>