Considering that you rely on jQuery (line 32) this can be replaced with:
`$.each(fields, function(value, name) {`