I'm trying to work out how to solve this JavaScript code challenge. I'm really struggling and would like some advice please?
I'm trying to improve on my ability to debug and I struggled with this one.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Clicker</title>
<meta name="description" content="">
<style></style>
</head>
<body>
<button>Click!</button>
<script>
const counter = {
cnt: 0,
inc: function() {
cnt++;
console.log(cnt);
}
};
const button = document.getElementsByTagName('button')[0];
button.addEventListener('click', counter.inc(), false);
</script>
</body>
</html>
But I get the error
Uncaught ReferenceError: cnt is not defined on line 19