I'm building an application that will allow users to click on a button and when they return to the page, it will show a message saying "Already interested". When I display the page, it skips over the if statement in the for loop and displays the else statement. What am I doing wrong?
Below is my code and current output.
<% for(var i=0; i < userInterests.length; i++) { %>
<% if ((username == userInterests[i].username) && (postID == userInterests[i].post_id)){ %>
<p>Already interested</p>
<% break; %>
<% } else { %>
<form action="/jobs/interested/<%= post._id %>" method='POST'>
<button type="submit" class="btn btn-info">I'm interested</button>
</form>
<% break; %>
<% } %>
<% } %>
ifstatement and see their values in the loop. That will give you a clear idea of why yourifstatement is evaluated as false.===instead of==.