Solution: Create a Smart Button

This code counts how many times a button is clicked and displays the total on the page.

Explanation:

  • A variable count starts at 0.

  • When the button with ID "toggle" is clicked, the function runs.

  • Each click increases count by 1.

  • The paragraph or element with ID "response" updates to show the message like “Clicked 3 times”.

Solution: Create a Smart Button

This code counts how many times a button is clicked and displays the total on the page.

Explanation:

  • A variable count starts at 0.

  • When the button with ID "toggle" is clicked, the function runs.

  • Each click increases count by 1.

  • The paragraph or element with ID "response" updates to show the message like “Clicked 3 times”.