Postgresql Loop Through Dictionary Javascript Interview