Passing variable from ejs to server file (node) / deleting a specific post in a loop

I print files from an array (that is stored in my app.js file) to a website using a for-loop in ejs:

  <% for(let i = 0;i<posts.length; i++){ %>
    <li class="listtitle">
         <%= posts[i].title %>
  <% } %>

Now I want to be able to remove a specific object from my array, I would use


The problem is that I don’t know how to export the “i” variable of a specific looped item from my ejs file to my app.js