'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



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source