Python Nested Function Variable Javascript Array Map