I have an array object containing multiple user IDs and hours worked. What I want to do, is count the hours worked for a specific user and once the hours have exceeded (299 for example) do something.
I want this logic tracked against the individual ID only, but currently, when the hours worked > 299 for a combination of users, then logic is fired. So currently if each user worked 100 hours each the logic would be triggered. I am working with datatables so will show my current logic below.
let newCount = 0;
var data = dataTable.rows().data();
console.log(data)
for (let i = 0; i < data.length; i++) {
if (data[i].employeeId == '1234' && hoursWorked > 299) {
newCount += data[i].hoursworked
console.log(newCount)
newNum = vol
}
console.log(newCount)
}
So to summarise I guess what I’m after is a way to only count the hours worked for a certain user ID.