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

121
Visualizações
If statement comparing two array values not completing when it should be

I have an array that i have made have two of the same value, i have made a function to check the array for duplicates but for some reason it never goes into the if statement. ( if(array[i] == array[j]) ).

when i is 0 and j is 1 they should be matching.

let sessions = [
    {"title": "Lecture", "sessionTime": new Date(2021, 8, 28, 9), "staff": "example"},
    {"title": "fake", "sessionTime": new Date(2021, 8, 28, 9), "staff": "example"},
    {"title": "Lab 1", "sessionTime": new Date(2021, 8, 28, 14), "staff": "example"},
    {"title": "Lab 2", "sessionTime": new Date(2021, 9, 1, 11), "staff": "example"}
];

errorCheck1 = function(sessions) {
    for (let i = 0; i < sessions.length; i++) {
        for (let j = 0; j < sessions.length; j++) {
            if (i != j) {
                if (sessions[i].sessionTime == sessions[j].sessionTime) {
                    $("#errors").append("<li>" + sessions[i].title + " clashes with " + sessions[j].title +"</li>");
                }
            }
        }
    }
}
about 4 years ago · Juan Pablo Isaza
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