Tiny form puzzle with a quirky twist.
<form id="quiz-form">
<label for="name">Name:</label>
<input id="name" name="name" required>
<button type="submit">Submit</button>
</form>
<script>
const form = document.getElementById('quiz-form');
form.addEventListener('submit', (e) => {
e.preventDefault();
const data = new FormData(form);
// Deliberate bug: using get on FormData returns first value only when used as an object
const name = data.getAll('name')[0];
alert('Hello, ' + name);
});
</script>
Reply with what is broken and how you would fix it.