I'm trying to shorten my code by using arrays, but I'm having trouble getting it to work. Can someone help me out?
// Task 1
var firstBox = document.getElementsByClassName('box1')[0]
firstBox.addEventListener("mouseenter", function(event) {
event.target.style.backgroundColor = "purple";
});
firstBox.addEventListener("mouseleave", function(event) {
event.target.style.backgroundColor = "white";
});
Thank you, Megi