Updated javascript converter to use local function variables when converting for-each loops.