I need to access an array(object object) in a EJS page, my setup is displaying an array brought from database.. I've come as far as displaying the object on the page, but when accessing I'm having a hard time..
I'm using the following code:
<% datacollection.forEach(function(data){ %>
<h1><%=data.name%></h1>
<% } %>
but with this I am getting a error:
SyntaxError: missing ) after argument list in C:\Users\FT\Desktop\foobase-master\project\html\pages\quotes.ejs while compiling ejs
or saying that same code is not a function if I add a ')' where I think it makes sense..
Help!
EDIT: How can I loop through this object array? Already tried a for loop but leaves a blank space, no entries.. **Using this:
<ul class="quotes">
<!-- Loop through quotes -->
<% for(var i = 0; i < datacollection.length; i++) {%>
<li class="quote">
<!-- Output name from the iterated quote object -->
<span><%= datacollection[i].name %></span>:
<!-- Output quote from the iterated quote object -->
<span><%= datacollection[i].quote %></span>
</li>
<% } %>
</ul>