I believe I’m very close but missing something. Even though it’s text content, it seems to be logging as a number but I can’t get it to increase beyond 1.
Hope that makes sense. (also my syntax needs practice so I’ll keep trying to clean that up).
Currently, when you click the green button, the following line executes:
let clicked = (document.querySelector(".num2").textContent = 1);
You assign the number
1 to the text of the div with class=“num2” and assign the div’s text value to
clicked. At this point,
clicked is equal to
1. The next line:
1 so it is now
Everytime you click on the green button
clicked will always end up being
2 at the end because you always assign it the value
1 and increment it by
1 to be
What I think you want is to display the incremented value each time you click on the green button.
There are several ways to do it, but the easiest would be to initialize
0 outside the click event listener for the green button and then inside the event listener, just increment
1 and then assign
clicked to the textContent property of the div with class=“num2”.
Ahhh - Thank you so much!!! There were points where I was assigning ‘clicked’ outside the event listener but then it wouldn’t do anything - My issue was that I never assigned ‘clicked’ to the textContent property f ‘num2.’ I was always assigning that either a 0 or 1.