Postgresql Loop Through Array Javascript Length Function In Js