How do you do a for loop/for each in EJS? How do you do a for loop/for each in EJS? express express

How do you do a for loop/for each in EJS?


So here's the example on embeddedjs:

    <ul><% for(var i=0; i<supplies.length; i++) {%>   <li><%= supplies[i] %></li><% } %></ul>

And here's what I did:

<% include ../../partials/header %> <<body>  <main>    <h1>List of all quotes</h1>    <ul>      <% for(var i = 0; i < author.length; i++) {        <li><%= author[i] %></li>      <% } %>      <% for(var i = 0; i < content.length; i++) {        <li><%= content[i] %></li>      <% } %>    </ul>  </main></body></html>


Let say you have a student JSON object with details of student name, year and course then you can loop through with forEach as follows.

<ul> <% students.forEach(function(student) { %>    <li> Name:<%= student.name %> Course:<%= student.course %></li> <% }); %> </ul>

The same can apply for your author and quote question above