How can I use if statement in ejs?

Something like this:

<% if(imgs.length > 0){ %>
    <% imgs.forEach(function(img) { %>
        <img src="uploads/<%=user.username%>/screenshots/<%= img %>">
    <% }); %>
<% } else{ %>  
    <p>no photos uploaded</p>
<% } %>

Reference


The shorthand version is correct, but it does have a syntax error

<%= role === 'admin' ? 'Super Admin' : 'Admin' %>

Or

<% if(role === 'admin'){ %>
    <p>Super Admin</p>
<% } else{ %>
    <p>Admin</p>
<% } %>

Yes , Here is short hand version :

<%= role == 'A' ? 'Super Admin' : 'Admin' %>