I’ve not very good at reading JS code, but this looks like the first iteration of this look would set
key = keys2[keys2[0]];
which isn’t going to work.
You could try replacing it with
for (key in keys2) {
However, when I Auto translate that I get
for (var key, _pj_c = 0, _pj_a = keys2, _pj_b = _pj_a.length; (_pj_c < _pj_b); _pj_c += 1) {
key = _pj_a[_pj_c];
It’s much easier if you use Auto translate components whenever possible