Why do we need a button and a function to access user input from an input element?

<html>
<head><style>body {min-height: 300px;} input { font-size: 16px; } textarea { font-size: 16px; } </style></head>
<body>
  <input id="questionInput" type="text" placeholder="Ask a question">
  <button onclick="ask()">Ask</button>

  <script>function ask() {
var question = document.getElementById("questionInput").value;
console.log(question);
}</script>
</body>
</html>]]>
Because the element's value changes when a user interacts with itBecause we want to display things in the console

We need a button and a function because the input element's value changes as a user interacts with it.