...

/

Introduction to Functions

Introduction to Functions

Get an overview of functions.

We'll cover the following...

So far, we’ve learned quite a bit about coding, and if you’ve been completing the challenges, we’ve already put together some small bits of code. Wouldn’t it be great if we could save those bits of code and run them at any time in a program? That’s what we can use functions for!

A function is a block of code that’s almost like a small, self-contained mini program. They can help to reduce repetition and make code easier to follow.

Functions are a perfect application of the DRY principle (“don’t repeat yourself”). We should always be trying to not repeat ourselves, thus cutting down on the amount of code we write. We do this all the time in real life. ...