I have two input type time. 1. time of entry 2. time of exit
Example 1:
Start: 00:00 end: 01:30 result: 1.5
Example 2 :
Start: 14:00 end: 00:00 result: 10
How to create an algorithm that calculates how many employees were at work?
This number will be multiplied by the rate he earns.
e.g. hours * rate (1.5 * 15)
I'd count work time in seconds cause its much clearer and fairy.
// Example data
const secondsWorked = 4321;
const rate = 15;
const secondsInHour = 3600;
const hoursWorked = secondsWorked / secondsInHour;
// Output: 1.2002777777777778
console.log("Hours worked: ", hoursWorked);
// Output: 18.0041666666666...
const income = hoursWorked * rate;
console.log("Calculated income: ", income);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With