Improve the solution

solution
Ryan Sobol 8 years ago
parent f6a2117f78
commit ba764541e2
  1. 28
      index.js

@ -31,29 +31,21 @@
}); });
// part 2 // part 2
stopButton.addEventListener('mouseenter', (event) => { const handleMouseEnter = function(event) {
console.log(`Entered ${event.target.textContent} button`); console.log(`Entered ${event.target.textContent} button`);
}); };
stopButton.addEventListener('mouseleave', (event) => {
console.log(`Left ${event.target.textContent} button`);
});
slowButton.addEventListener('mouseenter', (event) => {
console.log(`Entered ${event.target.textContent} button`);
});
slowButton.addEventListener('mouseleave', (event) => { const handleMouseLeave = function(event) {
console.log(`Left ${event.target.textContent} button`); console.log(`Left ${event.target.textContent} button`);
}); };
goButton.addEventListener('mouseenter', (event) => { stopButton.addEventListener('mouseenter', handleMouseEnter);
console.log(`Entered ${event.target.textContent} button`); slowButton.addEventListener('mouseenter', handleMouseEnter);
}); goButton.addEventListener('mouseenter', handleMouseEnter);
goButton.addEventListener('mouseleave', (event) => { stopButton.addEventListener('mouseleave', handleMouseLeave);
console.log(`Left ${event.target.textContent} button`); slowButton.addEventListener('mouseleave', handleMouseLeave);
}); goButton.addEventListener('mouseleave', handleMouseLeave);
// bonus // bonus
controls.addEventListener('click', (event) => { controls.addEventListener('click', (event) => {

Loading…
Cancel
Save