<svg>
<polygon
points="" style="fill: yellow; fill-opacity:0.5; stroke: black;"/>
</svg>
<script>
var coords = [{x:60,y:25},{x:140,y:25},{x:160,y:60},{x:80,y:60}];
var points = coords.reduce(function(sum, current) {
return sum + current.x + "," + current.y + " ";
}, "").trim();
document.querySelector('polygon').setAttribute('points', points);
</script>