Add a click listener to a button evaluates requirements, assumptions, structured reasoning, trade-offs, and verification in a realistic interview setting. A strong answer states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.
Given an HTML page that includes a button with the id 'my-button', write JavaScript to add a click event listener so that when the button is clicked, the button's text content is logged to the console. Use document.querySelector and addEventListener. Briefly explain what e.target refers to in this context.
Quick Answer: Add a click listener to a button evaluates requirements, assumptions, structured reasoning, trade-offs, and verification in a realistic interview setting. A strong answer states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.