For Loop Through An Array Javascript Length Function In Sql