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

210
Vistas
how not to include empty values in logic

I have this on my front-end (html)

<label for="sunday">Sunday</label>
<input type="checkbox" id="sunday" name="sunday" value="1">
<label for="monday">Monday</label>
<input type="checkbox" id="monday" name="monday" value="2">
<label for="tuesday">Tuesday</label>
<input type="checkbox" id="tuesday" name="tuesday" value="3">
<label for="wednesday">Wednesday</label>
<input type="checkbox" id="wednesday" name="wednesday" value="4">
<label for="thursday">Thursday</label>
<input type="checkbox" id="thursday" name="thursday" value="5">
<label for="friday">Friday</label>
<input type="checkbox" id="friday" name="friday" value="6">
<label for="saturday">Saturday</label>
<input type="checkbox" id="saturday" name="saturday" value="7">

then in my backend, i want to submit the ones that have been selected into the database. So i was thinking of writing something along the lines of:

var dates = {
        monday: req.body.monday,
        tuesday: req.body.tuesday,
        wednesday: req.body.wednesday,
        thursday: req.body.thursday,
        friday: req.body.friday,
        saturday: req.body.saturday,
        sunday: req.body.sunday
    }

    for (const item in dates) {
        console.log(item.value)
        if (item.value == undefined) {
            item = false
            console.log("undefined")
        }
    }
about 4 years ago · Juan Pablo Isaza
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