WARNING: This program counts the number of times a user clicks on the pig sprite, but it has a syntax error!

RULE: To use and change variables that were created earlier in the program in an event, we need to use the keyword global followed by the variable name that we would like to use inside of the event.

  • Click Run and click on the pig. Read the error message.
  • Use a Global Variable in the event so that 1 is added to clicks each time you click on the pig.

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)