By 
<% for (let i = 0; i < contacts.length; i++) { %>
    <a href="<%- contacts[i].url %>"><%- contacts[i].name %></a><% if(i == contacts.length - 2) { %> and <% } else if(i == contacts.length - 1) { %>.<% } else { %>, <% }%>
<% } %>