'How can I make it so if there is not an username in the database, I can render a message signaling that the username is anonimous using ejs?

<%if(campground.author.username.length) {%>         
    <li class="list-group-item">Submitted by <%=campground.author.username%> 
    </li>
    <% } else {  %>  
    <li class="list-group-item">Submitted by an anonymous author</li>
<% } %> 

I am trying to make it so if there is a username in the database the first li runs else the second runs



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source