workaround a BB10 JavaScript VM bug by doing forEach differently refs #17204

(cherry picked from commit ded3e6d2fcc6abf35eaa9a23eea96e30b34d372e)