Drill

ProblemsJavaScript › scheduling

Total minutes scheduled

easyschedulingJavaScript

A weekly grid lists every shift as a start and end in minutes past midnight. Add up the committed hours.

shiftTotal(shifts: list<Shift>) → int

Solve it in the editor →

Where you start

function shiftTotal(shifts) {
  
}

Worked examples

CallResult
shiftTotal([{"start":480,"end":900},{"start":900,"end":1080}])600
shiftTotal([{"start":0,"end":1440}])1440
shiftTotal([])0
shiftTotal([{"start":600,"end":600}])0

Hint

Sum of (end - start).

Reference solution in JavaScript
function shiftTotal(shifts) {
  let total = 0;
  for (const s of shifts) total += s.end - s.start;
  return total;
}

The same problem in another language

More scheduling problems in JavaScript