Your code is more complicated than it need be. There is no need for a nested function to do the math. You must also convert the user-supplied data to a number (this can be done by prepending a +
to the data).
Also, your code does not follow best-practices and standards.
See the comments in the code below.
// Get references to the HTML elements you'll use in JavaScript
var btn = document.getElementById("btn");
var output = document.getElementById("demo");
var counter = 0; // Running total will be here
// Set up event handling in JavaScript, not HTML
btn.addEventListener("click", function() {
counter += +prompt("What is the number to add?"); // Convert response to number and add to counter
output.textContent = counter; // Place result back into the document (use .textContent, not .innerHTML)
});
<button id="btn">+</button>
<p id="demo">0</p>