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

180
Visualizações
passing parameters to mouseenter/mouseout JS callbacks

I'm presented this challenge where the circle's color is to change depending on the type of cursor movement.

I must use the function toggleColor() in order to fill the circle with orange when the cursor moves onto it. Then, I got to reuse the same function to fill it in black once the cursor leaves it.

This must be done calling the toggleColor() with different values for the parameter isEntering. (In order to do this, I'm invoking the .toggleColor() function inside the callbacks of the .addEventListener()'s.

const element = document.querySelector('#element');

const toggleColor = (isEntering) => {
element.style.background = isEntering ? 'orange' : 'black';
};

element.addEventListener('mouseenter', ()=>toggleColor(true))
element.addEventListener('mouseout', ()=>toggleColor(false))

That's my solution to the challenge, and even though it does the work, the tests are not passing. Where am I failing at?

Here is the link to the challenge: https://www.jschallenger.com/javascript-dom-exercises/events-and-user-interactions/cursor-enter-leave-event

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