Hope someone can help,
On my site a user can log in and post a notice to the home page, they can then see all their notices and the user that posted the notice.
To show the notice author I am using the below map.
<% notices.map(notice => notice.author.username ) %>
<%= notice.author.username %>
Then I'm trying to say if there is no notice author (as in that user was deleted from the database) i want it to say "Author Unknown"
<% if (!notice.author.username) { %>
<p>Author Unknown</p>
<% } else {%>
<% notices.map(notice => notice.author.username ) %>
<%= notice.author.username %>
<% } %>
but the map seems to stop working in the conditional statement, any idea's???
Use,
<%- notices.map(notice => notice.author.username ) %>
Instead,
<% notices.map(notice => notice.author.username ) %>
The Javascript functions should be wrapped around <%- %>
If that does not work then ,
Try using for loop or forEach.