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

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

#1

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 %>
      </li>
  <% } %>

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

array.splice(i,1)

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