Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

179
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda