Swift Loop Through Array Javascript Methods Syntax