Loop Through String Array Javascript Length Function In R