Events are user actions (click, mouse over, key press) or browser actions (page load). With the addEventListener() method, you can set a function to run whenever an event happens.
javascript
// Assume HTML: <button id="myBtn">Click Me</button>
const button = document.getElementById("myBtn");
// button.addEventListener("click", function() {
// alert("Button was clicked!");
// });
console.log("Click the button on the page to see the event.");You should see
(Clicking the button pops up an alert box saying 'Button was clicked!')