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

202
Views
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
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!