I working with legacy code which uses underscore. I am trying to add an if else statement to the code which will check if the json is returning any value or not and if it doesn't it will return no value (hence the empty div).
Here is my code:
<% if(!_.isNull(datas.Recent)) {%>
<div></div>
<% } else { %>
<div class="contents"><%=datas.Recent%</div>
<% } %>
This code seems to be running the if statement exclusively which confuses me because of the code.
<% if(datas.Recent) {%>
<div class="contents><%=datas.Recent%</div>
<% } %>
Does return value/works as it was part of the original legacy code. Any idea what I am doing wrong with my use of the if else statement?