When we use alert(), some times the code breaks.
alert()
For example:
HTML:
Hi
Javascript:
Because you are catching the first click and showing an alert. The second click doesn't get caught because the alert now has the focus.
If you log to the console, then both clicks get caught and you will notice that "a" gets logged twice.