Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

101
Views
Display properties of an object based on value using express

I'm trying to display properties of an object based on value. So basically if they value of the property is equal to "film" the property should display. This is the code I have so far:

<% fidos.forEach(fido => { %>
        <%=fido.renown === "Film" %>
    <% }) %>

The browser returns:

true true false false false false false false

But I would like it to display the name and image for the 2 true ones. I believe I should try an if else statement but I'm not sure how to set it up. I've tried:

<% fidos.forEach(fido => { %>
         <% if fido.renown === "Film" { %>
            <%=fido.name%>
         <a href="/fidofame/<%=fido._id; %>">
            <<img class="image" src=<%=fido.image %> alt=<%=fido.name %>> -->
        <</a>
        <% } else %>
    <% }) %>

This returns a SyntaxError to the browser. I'm sorry for this basic question. I've only been programing for like 2 months.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You are missing parentheses on the if condition and quotation marks on src and alt. This should work:

<% fidos.forEach(fido => { %>
  <% if (fido.renown === "Film") { %>
    <%= fido.name %>
    <a href="/fidofame/<%= fido._id %>">
      <img class="image" src="<%= fido.image %>" alt="<%= fido.name %>" />
    </a>
  <% } %>
<% }) %>
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!