<html>
<body>
<h1>JavaScript Closures</h1>
<p>Counting with a local variable.</p>
<p id="demo"></p>
<script>
// Initiate counter
let counter = 0;
// Function to increment counter
function add() {
let counter = 0;
counter += 1;
}
// Call add() 3 times
add();
add();
add();
// The result is not 3 because you mix up the global and local counter
document.getElementById("demo").innerHTML = "The counter is: " + counter;
</script>
</body>
</html>