fork download
  1. const noBtn = document.getElementById("noBtn");
  2. const yesBtn = document.getElementById("yesBtn");
  3. const questionContainer = document.getElementById("questionContainer");
  4. const heartLoader = document.getElementById("heartLoader");
  5. const resultContainer = document.getElementById("resultContainer");
  6. const gifResult = document.getElementById("gifResult");
  7.  
  8. noBtn.addEventListener("mouseover", () => {
  9. const newX = Math.floor(Math.random() * questionContainer.offsetWidth);
  10. const newY = Math.floor(Math.random() * questionContainer.offsetHeight);
  11.  
  12. noBtn.style.position = "absolute";
  13. noBtn.style.left = `${newX}px`;
  14. noBtn.style.top = `${newY}px`;
  15. });
  16.  
  17. yesBtn.addEventListener("click", () => {
  18. setTimeout(() => {
  19. heartLoader.style.display = "none";
  20. resultContainer.style.display = "inherit";
  21. gifResult.play();
  22. }, 3000);
  23. });
  24.  
Success #stdin #stdout 0.03s 25644KB
stdin
Standard input is empty
stdout
const noBtn = document.getElementById("noBtn");
const yesBtn = document.getElementById("yesBtn");
const questionContainer = document.getElementById("questionContainer");
const heartLoader = document.getElementById("heartLoader");
const resultContainer = document.getElementById("resultContainer");
const gifResult = document.getElementById("gifResult");

noBtn.addEventListener("mouseover", () => {
    const newX = Math.floor(Math.random() * questionContainer.offsetWidth);
    const newY = Math.floor(Math.random() * questionContainer.offsetHeight);

    noBtn.style.position = "absolute";
    noBtn.style.left = `${newX}px`;
    noBtn.style.top = `${newY}px`;
});

yesBtn.addEventListener("click", () => {
    setTimeout(() => {
        heartLoader.style.display = "none";
        resultContainer.style.display = "inherit";
        gifResult.play();
    }, 3000);
});