Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

157
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda