• 4 hours
  • Easy

Free online content available in this course.

course.header.alt.is_video

course.header.alt.is_certifying

Got it!

Last updated on 6/15/21

Define and send messages with functions

Parameters and return values

You’ve just seen that functions communicate using messages.  They receive them through parameters which are what you feed our hungry function machine so that it can do its stuff. For example, if you had a GPS and wanted to check out your favorite burger or vegetarian place, you’d have to give it a starting point and endpoint, so that it could calculate your route.

Functions also give messages through what’s called return values.  In the GPS example, the function would return a route to get you from your house to a place where they serve good food. 🍔🥑

Try it out for yourself!

Think about programs you use on a daily basis, especially apps on your phone.  Do you have to give them any information? Do they give you information in return?

Choose one program and sketch it out as a magic function machine. What would you call it?  What are the parameters? What are the return values?

Summary

  • Functions can receive messages through parameters.

  • Functions can send messages through return values

Example of certificate of achievement
Example of certificate of achievement