I want to display array results in my database on the frontend using EJS.
So I have the following code:
var tagss = ["<%tags%>"]
<% for(var i=0; i<tagss.length; i++) { %>
<a href='<%= tagss[i] %>'> <%= tagss[i] %> </a>
</a>
<% } %>
But error message keeps telling me that tagss is undefined
Here is the full message:
full message:
ReferenceError: C:\xampp\htdocs\meme.africa\views\pages\meme.ejs:171
169|
170| var tagss = ["<%tags%>"]
>> 171| <% for(var i=0; i<tagss.length; i++) { %>
172|
173| <a href='<%= tagss[i] %>'> <%= tagss[i] %> </a>
174|
tagss is not defined
Please, what am I doing wrong?
<% %>is JS. The rest is the template. You need to make it code, not template. Like you did everywhere else you used it.