'show only one item with express/ejs/mongo
I've been trying to make a very simple ToDo list but when I want to show the description of the tasks, it displays all the descriptions, not only for that task itself. See the image, I want only one description by each task.

I'm using a forEach loop but idk if I should create a new variable to receive only the description of tasks. What can I do to show only one item from description and that's refer to the task.
Here is the EJS file:
<% todo.forEach(function(task) { %>
<div class="itens">
<li>
<a class="item" href="/edit/<%= task._id %>">
<%= task.task %>
</a>
<a class="item del-btn" href="/delete/<%= task._id %>" onclick="return confirm('Deseja excluir?');">
<img class="trash-icon" src="/images/trash.png" alt="">
</a>
<a class="item del-btn" href="/delete/<%= task._id %>" onclick="return confirm('Tarefa Concluida?');">
<img class="trash-icon" src="/images/done.png" alt="">
</a>
<% todo.forEach(function(desc) { %>
<p>
<%= desc.desc %>
</p>
<% }); %>
</li>
</div>
<% }); %>
Hey, I figure out what was the problem here. The second loop is what makes the description show duplicated and not only for the task.
Just erase the second loop and changes the <%= desc.desc %> to
<%= task.desc %> and will work fine!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
