Squash the bug — Claude

By (@sasam) ·

Tech stack

  • Claude

Prompt

I'm working on a simple to-do list web page (plain HTML and JavaScript). When I reload the page I get this error in the browser console:

Uncaught ReferenceError: addTdo is not defined
    at HTMLButtonElement.onclick (index.html:14)

Here is the code near line 14:

<button onclick="addTdo()">Add</button>
<script>
  function addTodo() {
    const text = document.getElementById('task').value;
    // ... adds the item ...
  }
</script>

I expected clicking the button to add a task. Can you explain what this error means and what's wrong, before telling me the fix?

5 views

Explore more on Prompted