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

185
Visualizações
Have this code so when a user presses the up or down key the balloon grows or shrinks. Need balloon to burst to "💥" when it reaches font size over 70

So far the balloon should only be able to reach max 70 font before it bursts. I need to turn the balloon into "💥". The event listener needs to be removed when the balloon bursts.

let para = document.querySelector('p');
para.style.fontSize = '24px';

window.addEventListener("keydown", e => {
  var sizeAsInteger = parseInt(para.style.fontSize, 10);

  if (e.key == "ArrowUp") {
    sizeAsInteger += 10;
  } else {
    sizeAsInteger -= 10;
  }

  para.style.fontSize = sizeAsInteger + 'px';
});
p {
  font-size: 50px;
}
<body>
  <p>🎈</p>
</body>

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Is this what you want?

let para = document.querySelector("p");

para.style.fontSize = "24px";

const increaseSize = e => {
  var sizeAsInteger = parseInt(para.style.fontSize, 10);

  if (sizeAsInteger >= 70) {
    window.removeEventListener("keydown", increaseSize);
    return (para.innerHTML = "💥");
  }

  if (e.key == "ArrowUp") {
    sizeAsInteger += 10;
  } else {
    sizeAsInteger -= 10;
  }

  para.style.fontSize = sizeAsInteger + "px";
};

window.addEventListener("keydown", increaseSize);
p {
  font-size: 50px;
}
<p>🎈</p>

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