Managing Multiple Timers in Javascript OH3

Please use code fences, not quotes, for code. How to use code fences

In answer to your question, use a function generator that you can pass values to.

function waitToChangeOccupanceGenerator(callingTimerId) {
  return function() {
    for(ArrayIndex ...
  }
}
...
ScriptExecution.createTimer(ZonedDateTime.now().plusMinutes(DelayPeriod), waitToChangeOcupancy(123));

But, for reference, I’ve a TimerMgr JavaScript library that odes all that management of multiple timers for you. https://github.com/rkoshak/openhab-rules-tools/tree/main/timer_mgr

Or, if you don’t want to rely on an external library, at least use a dict instead of an array to manage the Timers. Then you can just use the Item name as the index instead of needing to loop through the array.