I am currently iterating through an array of objects in the following manner:
<% for(post of posts) { %>
<% if(post.likes > 5){ %>
<div class="col">
<div class="card d-flex flex-column text-white mb-2" style="width: 18rem;">
<img src="<%=post.image%>" class="card-img" style="height: 300px;width: auto;" alt="...">
<div class="card-img-overlay align-self-end">
<h5 style="background-color: white;color: black;border-radius: 10px; text-align: center;" class="card-title"><%=post.title%> </h5>
<p style="text-shadow: 0.5px 0.5px 0.5px #00000050;" class="card-text"><%=post.content.slice(0,105)%>...</p>
<a href="/home/<%=post._id%>" class="btn btn-primary shadow">Continue Reading</a>
</div>
<div class="d-flex justify-content-between">
<div style="color: black;" class="card-footer bg-transparent"><%=post.likes%> <span> </span> <i style="color: red;" class="fas fa-heart d-inline"></i></div>
<% if(!post.date){ %>
<div style="color: black;" class="card-footer bg-transparent">Test Mode <span> </span> <i class="fas fa-calendar-alt"></i></div>
<% }else{ %>
<div style="color: black;" class="card-footer bg-transparent"><%=post.date%> <span> </span> <i class="fas fa-calendar-alt"></i></div>
<% } %>
</div>
</div>
</div>
<% } %>
<% } %>
My current code displays all items with likes greater than 5, however, I am aiming to display only 8 items with likes greater than 5. I have spent a considerable amount of time attempting to achieve this without success. Any assistance would be greatly appreciated as I am a beginner in this field!!