<script>
const tally ={
total: 0,
increase: function(){
total++;
console.log(total);
}
}
const selectBtn = document.getElementsByTagName('button')[0];
selectBtn.addEventListener('click', tally.increase, false);
</script>
When executing this code, I'll encounter an error due to an undefined variable. To resolve this, one solution is to include tally.total
within the function. However, I am looking for alternative approaches. Is there another method available?