2.4 - Custom Functions
This lesson is usually taught later, after the ability to make decisions (if-statements) and loop code. This year we will discuss functions first and see how that goes...
Review
We can output to the console with console.log()
We can use variables to hold, manipulate, and output data
Strings and Numbers are two different things
Strings can be concatenated using the `+` operator
We can make templates to insert values into sentences: `I am ${age} years old.`
We can do all sorts of maths like Math.round(x) and Math.floor(Math.random() * 10)
All that in a few Lessons!
Custom Functions:
What if we want to write some code that we can run whenever we want?
Custom Functions (sometimes called "User-Defined Functions") allow us to create mini-programs or "chunks of code" that we can use to complete repetitive or specific tasks.
The complete lesson and practice are in the repository for 2.4 - Custom Functions