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

116
Visualizações
Why is the resulting value of a combination of logical operations contradict each of them separately?

My JS code for displaying modal window in depending of values.

When I output values of event.pageY < 30, isMovingUp(event), event.movementY < 0 separetly all of them equals true but event.pageY < 30 && event.movementY < 0 && isMovingUp(event) equals false. Why it so?

const showModalBeforeOut = (event) => {
  const headerBlock = document.querySelector("#header");

  console.log(`${event.pageY < 30}`);
  console.log(`${isMovingUp(event)}`);
  console.log(`${event.movementY < 0}`);

  if (event.pageY < 30 && event.movementY < 0 && isMovingUp(event)) {

    console.log(`logical value of expression is: ${event.pageY < 30 && isMovingUp(event) && event.movementY < 0}`);

    let modalTextContent = "Don't leave the site!";
    let isCookieExists = checkCookie('max-age')
    if (!isCookieExists) {

    // if there is no cookie here at first display modal window and after initialize cookie with value `max-age`
      displayPopup(modalTextContent);
      document.cookie = 'max-age=15'

      if (document.body.contains(document.querySelector('.question-p'))) {
        const targetElement = document.querySelector('.question-p')
        targetElement.textContent = "Leaving already?"
      }
    }
  }
}
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