Js Loop External Variable Declaration Java