Swift Loop Through Array Javascript Methods