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

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