Python Function Inside Array Initialization Javascript Foreach