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

155
Views
Trying to separate sql DB values from each other
function absent() {
    const absent_date = new Date();
    const absent_days = absent_date.getDay();

    console.log("days", absent_days);
    let absent_remove = result_database.map(item => item.absentday)
    console.log("absent_remove", absent_remove);
    if (absent_remove == absent_days) {
        console.log("it works?")
        //resultStatement();
    } else {
        console.log("it doesnt work")
    }
}

I'm trying to separate the DB values below from each other, I have absent_remove 3 and 5, these numbers stand for the days someone is absent. From absent_days I would get lets say 5 (Friday), The DB value 3 should NOT be absent, and the DB value 5 SHOULD, but since they're in an array they interfer with each other, I need the DB value 5 to be selected everytime getDay() is 5. And DB val 3 when the day is 3. Anyone that can help me out here?

days 5
absent_remove [ 3, 5 ]
it doesnt work
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Use find() to return only the element that matches the current day.

function absent() {
    const absent_date = new Date();
    const absent_days = absent_date.getDay();
    console.log("days", absent_days);
    let absent_remove = result_database.map(item => item.absentday).find(day => day == absent_days)
    console.log("absent_remove", absent_remove);
    if (absent_remove == absent_days) {
        console.log("it works?")
        //resultStatement();
    } else {
        console.log("it doesnt work")
    }
}
about 4 years ago · Juan Pablo Isaza 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!