STEP 2: If we write a function with parameters, we can reuse it again and again with different arguments!

  • Define a function at the top of the program that is named cheer() and accepts one parameter named word.
  • Copy all of the code that you surrounded with comments and paste it properly indented inside the function.

The cheers in the program use repeated code, but one thing changes: the word to cheer! When code is used repetitively but with different values, we can use a function and parameter to change that value each time!

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)