Should it have the capital ‘S’ in it? I can’t see it spelt shown like that in the MDN ‘dragstart’ page If not, then it may be viewing it as an undefined variable.
There does seem to be a logic to what’s being reported, so it may be worth separating those functions out of the loop and calling them when required within it. I’m not sure whether that will necessarily help with dragstart being reported as undefined, but it may help clarify what’s happening.