STEP 15: Let's continue storing and returning damage until we can use it outside of all the functions.

  • Look inside cast_spell() to find the function calls for both fireball() and rock_smash().
  • Add a return variable in front of both function calls to store the returned value, like this: damage =

At this point, the damage value has come from calculate_damage() to fireball() or rock_smash() and is now in cast_spell()! If we return it one more time, we can use damage in the MAIN CODE section.

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)