Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

103
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda