function literal using loop