logo CodeStepByStep logo

printPay

Language/Type: JavaScript parameters

Write a function named printPay that computes and prints the amount of money an employee should earn. Your function accepts two parameters: anumber for the employee's hourly salary, and an integer for the number of hours the employee worked. Every hour over 8 is paid at 1.5x the normal salary. For example, the call of printPay(10.00, 11) should print the following output:

Hours worked: 11
Pay earned: $125.00

You may assume that the value passed for the salary and hours are non-negative.

Use the console.log() function to print each line of output and n.toFixed(2) to get a string of a number n to the precision of one decimal point. For example, if n is 1.2345, n.toFixed(2) would return "1.23".

Function: Write a JavaScript function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.